The sqrt() method returns the square root of a number.
The sqrt() method returns the square root of a number.
Math.sqrt(x)
Parameter | Require | Description |
---|---|---|
x | Required. | A number |
A Number. If x is a negative number, NaN is returned
Return the square root of a number:
//display the square root of 9. console.log(Math.sqrt(9));// ww w . j a v a 2 s .co m //Return the square root of different numbers: var a = Math.sqrt(0); var b = Math.sqrt(1); var c = Math.sqrt(9); var d = Math.sqrt(64); var e = Math.sqrt(-9); var x = a + "\n" + b + "\n" + c + "\n" + d + "\n" + e; console.log(x);