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.
Creates an array of numbers in the arithmetic progression, starting with the given positive integer and up to the specified limit.
Calculates the greatest common divisor between two or more numbers/arrays.
Sorts an array of numbers, using the bubble sort algorithm.
Initializes an array containing the numbers in the specified range where
start
andend
are inclusive and the ratio between two terms isstep
. Returns an error ifstep
equals1
.Calculates the difference between two strings, using the Levenshtein distance algorithm.
Returns the powerset of a given array of numbers.
Finds the index of a given element in a sorted array using the binary search algorithm.
Generates an array, containing the Fibonacci sequence, up until the nth term.
Finds the first index of a given element in an array using the linear search algorithm.
Finds the prime factors of a given number using the trial division algorithm.
Calculates the distance between two vectors.
Randomizes the order of the values of an array, returning a new array.
Calculates the least common multiple of two or more numbers.
Calculates the Hamming distance between two values.
Calculates the number of ways to choose
k
items fromn
items without repetition and without order.