问答详情
源自:7-16 随机数 random()

无法输出,是不是变量类型不对?

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
var shu=document.write(Math.random()*10+"<br/>");
document.write(Math.round("shu"));
</script>
</head>
<body>
</body>
</html>

提问者:有花不见叶 2016-07-11 18:22

个回答

  • 慕UI5360626
    2016-07-11 18:57:52
    已采纳

    <!DOCTYPE html>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Math </title>

    <script type="text/javascript">

    var c=Math.random()*10;

    var shu=document.write(c+"<br/>");

    document.write(Math.round(c)+"<br/>");

    </script>

    </head>

    <body>

    </body>

    </html>