<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
var mystr=[3.3,-0.1,-9.9,8.9];
for(var substr in mystr)
{
document.write(Math.ceil(substr)+"<br>");
}
</script>
</head>
<body>
</body>
</html>是遍历有问题吗?
1 回答
已采纳
刚毅87
TA贡献345条经验 获得超309个赞
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Math </title> <script type="text/javascript"> var mystr = [3.3, -0.1, -9.9, 8.9]; for(var substr in mystr) { document.write(Math.ceil(mystr[substr]) + "<br>"); } </script> </head> <body> </body> </html>
substr 只是数组的下标,只需把 substr 改为 mystr[substr]即可.
- 1 回答
- 0 关注
- 1122 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消