JavaScript Arithmetic (Math) Getting roots of a number

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Square Root

Use Math.sqrt() to find the square root of a number

Math.sqrt(16)   #=> 4

Cube Root

To find the cube root of a number, use the Math.cbrt() function

6
Math.cbrt(27)  #=> 3

Finding nth-roots

To find the nth-root, use the Math.pow() function and pass in a fractional exponent.

Math.pow(64, 1/6) #=> 2


Got any JavaScript Question?