Iterate through an array with a for loop questions on parameter 20

Hey. Having trouble figuring out how to get total=20 , not quite sure on how it could possibly equal 20. I’m pretty sure I’ve grasped the concept on how for loops work in the scenario, just not quite sure on this parameter of the completion check list. Here is my code:

// 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, 7, 8];

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

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

I’ve tried changing it back to that and it still doesn’t work,

after your instructions my code looks like this:


// 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
var total = 0;
for (var total = 0; i < myArr.length; i++){
  total += myArr[i];
}

Even so, it says in the console thing that the final total value is 6

EDIT: I fixed my own problem the real for loop should have looked like

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