Files
30-seconds-of-code/snippets/nthRoot.md
Isabelle Viktoria Maciohsek 8bf67754ce Make expertise a field
2022-03-01 20:21:45 +02:00

20 lines
374 B
Markdown

---
title: Nth root of number
tags: math
expertise: beginner
firstSeen: 2021-01-06T22:47:48+02:00
lastUpdated: 2021-01-06T22:47:48+02:00
---
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`.
```js
const nthRoot = (x, n) => Math.pow(x, 1 / n);
```
```js
nthRoot(32, 5); // 2
```