javascript
Calculate square root of a number using javascript
To find the square root of a number you can use Math.sqrt() function of javascript. It will return the square root value of the given number.
const num = 100;
const sqrt = Math.sqrt(num);
Output
10
In the code snippet we are calculating the square root of a number which has 100 as value. We are passing this variable to the Math.sqrt() function of javascript and it is returning the value 10.
Math.sqrt() function
Math.sqrt() method in javascript is used to get the square root value of a number. It takes the number as the required parameter. The syntax is as below.
Math.sqrt(number)
Live Demo
A live demo for this getting square root of the number is as below.
More Examples
Math.sqrt(100);
Math.sqrt(200);
Math.sqrt(50);
Math.sqrt(60)
Was this helpful?
Similar Posts
- Calculate the frequency of characters in a string using Javascript
- Check if a number is odd or even using Javascript
- Simplest Way to Find the Smallest Number in an Array using JavaScript
- Find the Third Smallest Number in an Array using Javascript
- Using regex to validate a phone number in Javascript
- Convert a Number or Integer to String in Javascript
- Convert a String to Number or Integer in Javascript