didikee - 博客园

二维数组

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>二维数组</title>
</head>
<body>
<script>
    let score=
        [
        [12,15,78],
        [76,78.5,79.8],
        [84.1,85,84]]
    let total;
    let max;
    let min;
    let avg;
    for (let i = 0; i <score.length ; i++) {
        total=0
        max=min=score[i][0]
        for (let j = 0; j<score[i].length; j++) {
            //score[i].length表示第i个数组里面含有多少个数值;
            total+=score[i][j];
           if(score[i][j]>max) max=score[i][j];
            if(score[i][j]<min) min=score[i][j];
        }
        avg=total/score[i].length;
        let  str=`第${i+1}个班的总分为:${total},平均分为${avg},最高分为${max}最低分为${min}`
        console.log(str)

    }
</script>
</body>
</html>

 

posted @ 2019-07-03 21:27  排雷兵  阅读(211)  评论(0编辑  收藏  举报
//粒子吸附特效
  
*
*
*
*
*
*
*
*
*
*
*
*
*