I ran this code for the section “Iterate Through an Array with a For Loop”, but it keeps saying that total should be declared and initialized to 0, and not to set it to 20. I have done precisely both of those things, but it’s still giving me an error.
// 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];
}
I still don’t quite understand what that means; do I replace the 0 with an a? It returns undefined when I do that. I put in myArr, but it still doesn’t return all green. How would you write the line that’s messing the program up?