Start of main content
## 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.

### Merge sort

Sorts an array of numbers, using the merge sort algorithm.

JavaScript, Algorithm · Dec 27, 2020

### Arithmetic progression

Creates an array of numbers in the arithmetic progression, starting with the given positive integer and up to the specified limit.

JavaScript, Math · Oct 13, 2021

### Bubble sort

Sorts an array of numbers, using the bubble sort algorithm.

JavaScript, Algorithm · Dec 29, 2020

### Greatest common divisor

Calculates the greatest common divisor between two or more numbers/arrays.

JavaScript, Math · Dec 29, 2020

### Insertion sort

Sorts an array of numbers, using the insertion sort algorithm.

JavaScript, Algorithm · Dec 28, 2020

### Geometric progression

Initializes an array containing the numbers in the specified geometric progression range.

JavaScript, Math · Dec 28, 2020

### Binary search

Finds the index of a given element in a sorted array using the binary search algorithm.

JavaScript, Algorithm · Dec 29, 2020

### Levenshtein distance

Calculates the difference between two strings, using the Levenshtein distance algorithm.

JavaScript, String · Dec 29, 2020

### Fibonacci

Generates an array, containing the Fibonacci sequence, up until the nth term.

JavaScript, Math · Dec 28, 2020

### Linear search

Finds the first index of a given element in an array using the linear search algorithm.

JavaScript, Algorithm · Dec 28, 2020

### Prime factors of number

Finds the prime factors of a given number using the trial division algorithm.

JavaScript, Math · Dec 28, 2020

### Least common multiple

Calculates the least common multiple of two or more numbers.

JavaScript, Math · Dec 28, 2020

### Shuffle array

Randomizes the order of the values of an array, returning a new array.

JavaScript, Array · Feb 20, 2021