//使用for...in语句
<script type="text/javascript">
var classmates,i;
classmates = new Array("张跃","马良","张力");
for (i in classmates) document.writeln("第"+(parselnt(i)+1)+"个同学是:"+classmates[i]) ;
</script>
慕姐5694721
浏览 1414回答 3
3回答
柠檬酸钠
第五行preseInt楼主写成了parseLnt,还有呢,就是一行代码也最好加上大括号,提高代码可读性 var classmates = new Array("张跃","马良","张力");
for (var i in classmates) {
document.writeln("第"+(parseInt(i)+1)+"个同学是:"+classmates[i]);
}