Here you can find a number of examples on Java Script.Please find the various kinds of examples listed on the right side of this site. If you don't find anything on Java Script then please write to us or leave a commnet. We are pleased to help and find the solution of your problem.

JavaScript: Squareroot Function



sqrt Function :-
Returns the square root of a number.

Suntax :-
sqrt(number)

Description :-
If the value of number is negative,sqrt returns NaN. Because sqrt is a static method of Math,you always use it as Math.sqrt(), rather than as a method of a Math object you created.



Example:

<html>
<head>
<title>Calculate Squareroot</title>

<script language="javascript">
function calcsqrt()
{
var value=f1.sqrt.value;
alert("The Squareroot of " + value + " is " + Math.sqrt(value));
}
</script>

</head>
<body>

<form name="f1">
<input type="text" name="sqrt" value="Enter Number" size="20">
<input type="button" value="Calculate" onclick="calcsqrt()">
</form>

</body>
</html>

2 comments:

Google