How to use sqrt in JavaScript
In this article, I will explain use of sqrt() method in JavaScript.
JavaScript sqrt() Method
-
sqrt() method of math object returns the square root of a number.
-
In sqrt() method, the value of number is negative, sqrt method returns none.
Syntax
Example
In the following example show to sqrt() method returns square root of value of numbers.
<html>
<head>
<title>JavaScript Math sqrt() Method</title>
</head>
<body>
<h3 style="color:red">JavaScript sqrt() Method Example</h3>
<script type="text/javascript">
var a = Math.sqrt(25);
document.write("First Test square root Value : " + a);
var b = Math.sqrt(36);
document.write("<br />Second Test square root Value : " + b);
var c = Math.sqrt(5);
document.write("<br />Third Test square root Value : " + c);
var d = Math.sqrt(-4);
document.write("<br />Fourth Test square root Value : " + d);
</script>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here