switch的写法不会啊~有木有会的小伙伴呐
for循环的好理解 对switch不晓得怎么写
for循环的好理解 对switch不晓得怎么写
2016-07-06
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>流程控制语句</title>
<script type="text/javascript">
//第一步把之前的数据写成一个数组的形式,定义变量为 infos
var gril=new Array()
var stu=[["小A","女",21,"大一"],["小B","男",23,"大三"],["小C","男",24,"大四"],["小D","女",21,"大一"],["小E","女",22,"大四"],
["小F","男",21,"大一"],["小G","女",22,"大二"],["小H","女",20,"大三"],["小I","女",20,"大一"],["小J","男",20,"大三"]];
document.write("stu:"+stu.length+"<br>");//总的学生数量
//第一次筛选,找出都是大一的信息
for(var i=0;i<stu.length;i++){
switch (stu[i][3]){
case "大一":
gril[gril.length]=stu[i];
document.write("大一的学生有:"+stu[i]+"<br>");
break;
}
}
document.write("gril:"+gril.length+"<br>");//大一的学生数量
//第二次筛选,找出都是女生的信息
for(var j=0;j<gril.length;j++){
switch (gril[j][1]){
case "女":
document.write("大一的女学生有:"+gril[j][0]+"<br>");
break;
}
}
</script>
</head>
<body>
</body>
</html>
举报