Iterate through an array challenge

please i need a break down on this challenge,so i could solve it.

  **Your code so far**

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

// Only change code below this line
for (var  i = 0; i < arr.length; i++) {
console.log(arr[i])
}
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0

Challenge: Iterate Through an Array with a For Loop

Link to the challenge:

Since you only copied the example and changed let to var (don’t use var!!!), I’m not sure what you do or don’t understand.

The instructions say

Declare and initialize a variable total to 0 . Use a for loop to add the value of each element of the myArr array to total .

I don’t see a variable total. Do you know how to declare a variable? Do you know how to initialize a variable?

I also don’t see you adding anything together inside of your loop. Do you know how to add values together in Javascript?

yes i can declare and also initialiazee a variable.just that i did not understand what i was tasked to do.most problem i have is not understanding the question.once i do i could actually tackle it from there.google is my friend

Ok, do you have questions about what you are being asked to do?

just needed to understand the task.that was why i asked for breakdown

I’m not sure what part of the instructions you don’t understand though…

Declare and initialize a variable total to 0 .

You said you know how to do this (though, you have not done this yet)

Use a for loop to add the value of each element of the myArr array to total .

You said you know how to add values, and you posted code where you were using a for loop to print all elements in your array…

So what exactly don’t you understand?

If you just want me to use different words to describe the problem so you can Google the answer and copy it - that’s just silly and won’t help you learn.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.