Iterate Through an Array with a For Loop - Output total = 0 even though the code is correct

Iterate Through an Array with a For Loop - Output total = 0 even though the code is correct
0

#1

Hello,

I don’t seem to understand why the below code gives output as total = 0 instead of 20.

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 += myArr[i];
}


#2

Try with length instead of your lenght line 16 :wink:


#3

Thanks, Nabi… :face_with_hand_over_mouth::rofl::rofl: