JavaScript Math Object : sqrt()

The sqrt() method returns the square root of given number and if the value of a number is negative, than it returns null. Syntax :test
  Math.sqrt( number);
Example :
<script>
  var x = 4;
  var y = Math.sqrt(x);
  document.write("sqrt(2) : " + y + "<br/>");
  var x = 25;
  var y = Math.sqrt(x);
  document.write("sqrt(25) : " + y + "<br/>");
  var x = 9;
  var y = Math.sqrt(x);
  document.write("sqrt(9) : " + y + "<br/>");
  var x = 3;
  var y = Math.sqrt(x);
  document.write("sqrt(3) : " + y + "<br/>");
</script>
Output :



Next Topic :