192k views
1 vote
Can someone explain this question & answer to me?

var list = [11, 35, 6, 0];
var sum = 0;

for (var i = 0; i < list.length; i++) {
sum = sum + list[i];
}
sum = sum/list.length;
console.log(sum);

User Rmlan
by
8.1k points

1 Answer

4 votes
The code iterates through the list of numbers and adds them up.
The sum is then divided by the length of the list to get a percentage.
The code will iterate through the list of numbers and add them up.
The sum variable is then divided by the number of items in the list to determine the average value.
User Soren Stoutner
by
7.6k points