 ## JavaScript Math Snippets

The JavaScript snippet collection contains a wide variety of ES6 helper functions. It includes helpers for dealing with primitives, arrays and objects, as well as algorithms, DOM manipulation functions and Node.js utilities.

• ### Hash string into number

Hashes the input string into a whole number.

JavaScript, Math · Oct 22, 2020

• ### Prime factors of number

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

JavaScript, Math · Dec 28, 2020

• ### Random integer array in range

Generates an array of `n` random integers in the specified range.

JavaScript, Math · Oct 22, 2020

• ### Vector distance

Calculates the distance between two vectors.

JavaScript, Math · Dec 28, 2020

• ### Array symmetric difference

Returns the symmetric difference between two arrays, without filtering out duplicate values.

JavaScript, Array · Oct 22, 2020

• ### Closest numeric match

Finds the closest number from an array.

JavaScript, Math · Mar 30, 2022

• ### RGB to hex

Converts the values of RGB components to a hexadecimal color code.

JavaScript, String · Nov 3, 2020

• ### Standard deviation

Calculates the standard deviation of an array of numbers.

JavaScript, Math · Oct 22, 2020

• ### Vector angle

Calculates the angle (theta) between two vectors.

JavaScript, Math · Jan 8, 2021

• ### Weighted average

Calculates the weighted average of two or more numbers.

JavaScript, Math · Nov 3, 2020

• ### Array unique symmetric difference

Returns the unique symmetric difference between two arrays, not containing duplicate values from either array.

JavaScript, Array · Oct 22, 2020

• ### Array similarity

Returns an array of elements that appear in both arrays.

JavaScript, Array · Oct 22, 2020

• ### Average of numbers

Calculates the average of two or more numbers.

JavaScript, Math · Oct 22, 2020

• ### Least common multiple

Calculates the least common multiple of two or more numbers.

JavaScript, Math · Dec 28, 2020

• ### Percentile of matches

Calculates the percentage of numbers in the given array that are less or equal to the given value.

JavaScript, Math · Oct 22, 2020

3