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.
Groups the given data into k
clusters, using the k-means clustering algorithm.
JavaScript, Algorithm · Dec 29, 2020
Classifies a data point relative to a labelled data set, using the k-nearest neighbors algorithm.
JavaScript, Algorithm · Oct 13, 2021
Implements the Luhn Algorithm, used to validate a variety of identification numbers.
JavaScript, Math · Jan 30, 2022
Generates all permutations of an array's elements (contains duplicates).
JavaScript, Array · Dec 28, 2020
Sorts an array of numbers, using the heapsort algorithm.
JavaScript, Algorithm · Dec 28, 2020
Sorts an array of numbers, using the bucket sort algorithm.
JavaScript, Algorithm · Dec 29, 2020
Finds all the indexes of a substring in a given string.
JavaScript, String · Dec 31, 2020
Sorts an array of numbers, using the quicksort algorithm.
JavaScript, Algorithm · Oct 13, 2021
Learn everything you need to know about Big-O notation with this handy cheatsheet.
JavaScript, Algorithm · Jan 8, 2023
Encrypts or decrypts a given string using the Caesar cipher.
JavaScript, Algorithm · Dec 29, 2020
Sorts an array of numbers, using the selection sort algorithm.
JavaScript, Algorithm · Oct 13, 2021
Counts the occurrences of a substring in a given string.
JavaScript, String · Jan 7, 2021
Generates primes up to a given number, using the Sieve of Eratosthenes.
JavaScript, Math · Dec 28, 2020
Calculates the distance between two points in any number of dimensions.
JavaScript, Math · Dec 28, 2020
Finds a contiguous subarray with the largest sum within an array of numbers.
JavaScript, Algorithm · Sep 7, 2022