Iterate through an Array with a For loop help please

Struggling with this one. I presume my for loop will iterate through the array but I don’t know how to access the values in the array to add them together as a sum.
As a complete beginner I don’t know how you guys do all this!

My code is below;

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36.

Challenge: Iterate Through an Array with a For Loop

Link to the challenge:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


You’re missing something important here. Can you figure out what it is?

Got it! " myArr[i]". Thank you so much.

So next time code like this…

my code

Thank you for helping me with my etiquette on the forum too.

1 Like

Easy mistake to make. You’ll get good at finding typos soon.