Start of main content## Recommended snippets

Calculates the nth root of a given number.

- Use
`Math.pow()`

to calculate`x`

to the power of`1 / n`

which is equal to the nth root of`x`

.

`const nthRoot = (x, n) => Math.pow(x, 1 / n);`

`nthRoot(32, 5); // 2`

Would you like to help us improve 30 seconds of code?Take a quick survey

### Percentile of matches

JavaScript, Math

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

### Logarithm in specific base

JavaScript, Math

Calculates the logarithm of the given number in the given base.

### Primes up to given number

JavaScript, Math

Generates primes up to a given number, using the Sieve of Eratosthenes.