Math Function sqrt
Math.sqrt(x)
1.Math.sqrt(x) takes a number as an argument and returns the square root of that number.
2.The argument is a numeric expression.
3.If a negative number is passed through the argument, for instance Math.sqrt(-9) , the function will return NaN.
Example
<script type="text/javascript">
var n = prompt("Enter a number");
var answer = Math.sqrt(n);
alert("The square root of" +n+ "is" +answer);
</script>
var n = prompt("Enter a number");
var answer = Math.sqrt(n);
alert("The square root of" +n+ "is" +answer);
</script>
No comments:
Post a Comment