城南旧梦情
2017-07-21 11:26
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
x=3.3
x=-0.1
x=-9.9
x=8.9
document.write(Math.ceil(x)+"<br />")
</script>
</head>
<body>
</body>
</html>
谁能用之前所学的循环来做一下
<script type="text/javascript">
var x =[3.3,-0.1,-9.9,8.9];
for(var i=0;i<x.length;i++){
document.write(Math.ceil(x[i])+"<br/>")
}
</script>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
var myarray = [3.3,-0.1,-9.9,8.9];
for(i=0;i<=3;i++)
{
document.write(Math.ceil(myarray[i])+"<br />")
}
</script>
</head>
<body>
</body>
</html>
写了一个,还有其他方法吗 简单便捷
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题