js2---60,每五个数取平均值
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var arr=new Array(30);
var num=0;
for(var i=0;i<arr.length;i++){
num+=2;
// console.log(num);
arr[i]=num
}
console.log(arr);
var newArr=[];
var sum=0;
for(var j=0;j<arr.length;j++){
// console.log(arr[j]);
// sum+=arr[j];
if((j+1)%5===0){
newArr.push(sum/5);
sum=0;
}
}
console.log(newArr);
</script>
</body>
</html>