JavaScript Algorithms
The JavaScript algorithms collection includes implementations and examples of popular algorithms in ES6. Algorithmic snippets are primarily a learning resource, as they might already be implemented natively or require optimizations to run in production.
kMeans
JavaScript, Algorithm
Groups the given data into
k
clusters, using the k-means clustering algorithm.kNearestNeighbors
JavaScript, Algorithm
Classifies a data point relative to a labelled data set, using the k-nearest neighbors algorithm.
luhnCheck
JavaScript, Math
Implementation of the Luhn Algorithm used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers etc.
quickSort
JavaScript, Algorithm
Sorts an array of numbers, using the quicksort algorithm.
indexOfSubstrings
JavaScript, String
Finds all the indexes of a substring in a given string.
bucketSort
JavaScript, Algorithm
Sorts an array of numbers, using the bucket sort algorithm.
heapsort
JavaScript, Algorithm
Sorts an array of numbers, using the heapsort algorithm.
permutations
JavaScript, Array
Generates all permutations of an array's elements (contains duplicates).
selectionSort
JavaScript, Algorithm
Sorts an array of numbers, using the selection sort algorithm.
caesarCipher
JavaScript, Algorithm
Encrypts or decrypts a given string using the Caesar cipher.
primes
JavaScript, Math
Generates primes up to a given number, using the Sieve of Eratosthenes.
countSubstrings
JavaScript, String
Counts the occurrences of a substring in a given string.
euclideanDistance
JavaScript, Math
Calculates the distance between two points in any number of dimensions.
arithmeticProgression
JavaScript, Math
Creates an array of numbers in the arithmetic progression, starting with the given positive integer and up to the specified limit.
gcd
JavaScript, Math
Calculates the greatest common divisor between two or more numbers/arrays.