Iterate though an Array with a for loop

check my code

Your code so far


// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var total = 0;
for (var i = 0; i<=myArr.length; i++) {
total += myArr[i];
}
console.log(total);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36.

Challenge: Iterate Through an Array with a For Loop

Link to the challenge:

Hello there.

Do you have a question?

You seem to have accidentally deleted the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.

That for loop does not look right. Try consoling what array.length returns. And, note your loop index is starting from zero.

We old timers refer to this as a fencepost error: