慕粉1440489053
2017-02-28 00:02
var infor=[["小A","女",21,"大一"],["小B","男",23,"大三"],["小C","男",24,"大四"],["小D","女",21,"大一"],["小E","女",22,"大四"],["小F","男",21,"大一"],["小G","女",22,"大二"],["小H","女",20,"大三"],["小I","女",20,"大一"],["小J","男",20,"大三"]];
switch(infor[i][3]==="大一"&&infor[i][1]==="女"){
case true:
document.write("大一女生信息:"+infor[i]);
break;
}
/*我也是最进才学的,这是我的方法你看行不行. ①你应该是像楼上说的没加for或其他循环语句;②且条件要一个个放,不然循环输出会出错,就不显示了;③下面是我多次修改的代码,让我们共同进步!: */ var infor=[ ["小A","女",21,"大一"],["小B","男",23,"大三"], ["小C","男",24,"大四"],["小D","女",21,"大一"], ["小E","女",22,"大四"],["小F","男",21,"大一"], ["小G","女",22,"大二"],["小H","女",20,"大三"], ["小I","女",20,"大一"],["小J","男",20,"大三"] ]; document.write("<b>大一女生:</b><br/>"); for(var i=0;i<10;i++){ switch(infor[i][3]){ case "大一": document.write("大一女生信息:"+infor[i]+"<br/>"); break; } } document.write("<br/><b>女生姓名:</b><br/>"); for(var i=0;i<10;i++){ switch(infor[i][1]){ case "女": document.write("大一女生信息:"+infor[i][0]+"<br/>"); break; } }
找到原因了 没有写FOR循环
JavaScript进阶篇
468194 学习 · 21891 问题
相似问题
回答 2
回答 2
回答 2
回答 3
回答 1