Iterate Through an Array with a For Loop: "total should equal 20"?

Tell us what’s happening:

So I was able to complete this challenge no problem but, I just had a question about "total should equal 20", where do we get 20 from?

Your code so far


// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}

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

// Only change code below this line


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop/

If you sum all the numbers in myArr you will get 20, that’s where you get it from. When you use the for loop to iterate thru this array you are just summing all the array values into a variable as you can see in the example.

1 Like

says something ridiculously stupid.