对象

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>

<body>
<script>
var x,square_root; //定义变量x和square_root;
x=parseFloat(prompt("x=","0")); //把弹框输入数字转成浮点数,赋值给变量x;
square_root=Math.sqrt(x); //求出x的平方根赋值给变量square_root;Math是js中内置对象,sqrt是这个对象所提供的函数;
alert(x+"的平方根="+square_root); //弹出变量square_root;
</script>
</body>
</html>

 

posted @ 2016-09-19 15:32  Jinsuo  阅读(120)  评论(0编辑  收藏  举报