Iterate Through an Array with a For Loop HELP!

Tell us what’s happening:
Hi, i don’t understand why the loop is returning “0”, instead the sum of all the elments inside the array.

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.lenght; i++) {
total = 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/81.0.4044.138 Safari/537.36.

Challenge: Iterate Through an Array with a For Loop

Link to the challenge:

This is spelled wrong. :slight_smile:

my GOD!

:+1: :love_you_gesture:

1 Like