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.

### Maximum subarray

JavaScript, Algorithm

Finds a contiguous subarray with the largest sum within an array of numbers.

### Merge sort

JavaScript, Algorithm

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

### Greatest common divisor

JavaScript, Math

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

### Powerset

JavaScript, Math

Returns the powerset of a given array of numbers.

### Bubble sort

JavaScript, Algorithm

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

### Insertion sort

JavaScript, Algorithm

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

### Geometric progression

JavaScript, Math

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

### Binary search

JavaScript, Algorithm

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

### Levenshtein distance

JavaScript, String

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

### Fibonacci

JavaScript, Math

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

### Linear search

JavaScript, Algorithm

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

### Prime factors of number

JavaScript, Math

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

### Vector distance

JavaScript, Math

Calculates the distance between two vectors.

### Least common multiple

JavaScript, Math

Calculates the least common multiple of two or more numbers.

### Shuffle array

JavaScript, Array

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