问答详情
源自:4-10 编程练习

关于二维数组的条件筛选输出

忽略掉全都是一样的信息这个“bug”,嫌麻烦所以复制的,题目是:输出所有是大一的女生,请问这代码哪写错了,为啥一个都输出不了呢,请指正

 var infos[["小a","女",21,"大一"],["小b","女",21,"大一"],["小c","女",21,"大一"],["小d","女",21,"大一"],["小e","女",21,"大一"],["小f","女",21,"大一"],["小g","女",21,"大一"],["小h","女",21,"大一"],["小i","女",21,"大一"],["小j","女",21,"大一"]];

 for(var i=0;i<infos.length;i++){
     var jr=infos[i][3];
     var wx=infos[i][1];
     if(wx=="女" && jr=="大一"){
         document.write(infos[i]+"<br/>");
     }
 }

提问者:Lucifer_竹岚 2016-05-27 16:10

个回答

  • 啊LANG3214178
    2016-05-27 16:29:09
    已采纳

    var infos后面少了个"="

  • 辰_ger
    2016-05-27 18:17:46

    定义数组的时候少了个 “=”

  • hgliuxiong
    2016-05-27 17:09:33

    定义数组的时候没有赋值号

  • wyz_nana1026
    2016-05-27 16:29:19

     定义二维数组的时候,需要加等号

    var infos = [["小a","女",21,"大一"]...]