Square Root in Javascript
In this article, we will see how to square root in javascript. We can use math.sqrt() method to find the square root value easily. We can give the number to find the square root. Math contains many methods like signs, abs, sqrt, pow, etc. So, let’s see how to do that in practice.
Math object
A math object is a built-in object, that contains basic mathematical functions and constants.
How to use the square root method
<script type="text/javascript">
document.write(Math.sqrt(9), "<br/>");
document.write(Math.sqrt(100), "<br/>");
document.write(Math.sqrt(81), "<br/>");
document.write(Math.sqrt(121), "<br/>");
document.write(Math.sqrt(49), "<br/>");
</script>
Output:
In this above code, we have to use the “Math.sqrt()” function and give the value 9 inside it, 9 square is 3 so it returns 3.