<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<script type= "Text/javascript" >
Defines an array of 30 integer elements, giving an even number starting from 2 in order, and then averaging each of the five numbers in order, placing them in another array and outputting them.
var arr = [];
var NewArr = [];
var average = 0;
Arr.length = 30;
for (var i = 1; I <= arr.length; i++)
{
Arr[i-1] = 2*i;
Assign arr Arr[i-1] because the array subscript starts at 0
if (i% 5!== 0)
Make a judgment of the five numbers as a group and then put the average of each group into another array
{
Average + = arr[i-1];
}else
{
Newarr.push (AVERAGE/5);
Average = 0;
}
}
Console.log (arr);
Console.log (NEWARR);
</script>
<body>
</body>
↓
Defines an array of 30 integer elements, giving an even number starting from 2 in order, then averaging each of the five numbers in order, placing them in another array and outputting