Math.sqrt method
The Math.sqrt method returns
the square root of a number.
Syntax
javascriptMath.sqrt(positive number);
Example
Let's take the square root
of 4:
javascriptconsole.log(Math.sqrt(4));
The code execution result:
javascript2
Example
Let's get the square
root of 15:
javascriptconsole.log(Math.sqrt(15));
The code execution result:
javascript3.872983346207417
Example
Let's take the square root of
-100. Since a negative number is
passed, NaN will be displayed:
javascriptconsole.log(Math.sqrt(-100));
The code execution result:
javascriptNaN
See also
-
the
Math.powmethod
that raises a number to a given power