offline version v3


37 of 264 menu

Math.sqrt method

The Math.sqrt method returns the square root of a number.

Syntax

Math.sqrt(positive number);

Example

Let's take the square root of 4:

console.log(Math.sqrt(4));

The code execution result:

2

Example

Let's get the square root of 15:

console.log(Math.sqrt(15));

The code execution result:

3.872983346207417

Example

Let's take the square root of -100. Since a negative number is passed, NaN will be displayed:

console.log(Math.sqrt(-100));

The code execution result:

NaN

See also

  • the Math.pow method
    that raises a number to a given power
enru