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.

  • arithmeticProgression

    JavaScript, Math

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

  • binarySearch

    JavaScript, Algorithm

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

  • binomialCoefficient

    JavaScript, Math

    Calculates the number of ways to choose k items from n items without repetition and without order.

  • bubbleSort

    JavaScript, Algorithm

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

  • caesarCipher

    JavaScript, Algorithm

    Encrypts or decrypts a given string using the Caesar cipher.

  • countSubstrings

    JavaScript, String

    Counts the occurrences of a substring in a given string.

  • distance

    JavaScript, Math

    Calculates the distance between two points.

  • factorial

    JavaScript, Math

    Calculates the factorial of a number.

  • isPrime

    JavaScript, Math

    Checks if the provided integer is a prime number.

  • linearSearch

    JavaScript, Algorithm

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

  • powerset

    JavaScript, Math

    Returns the powerset of a given array of numbers.

  • primeFactors

    JavaScript, Math

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

  • vectorDistance

    JavaScript, Math

    Calculates the distance between two vectors.

  • bucketSort

    JavaScript, Algorithm

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

  • euclideanDistance

    JavaScript, Math

    Calculates the distance between two points in any number of dimensions.