Getting roots of a number
suggest changeSquare 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
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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents