Basic JavaScript - Iterate with JavaScript For Loops

Tell us what’s happening:
Describe your issue in detail here.
I’m not sure why i’m still getting wrong. It still says: " Failed:myArray should equal [1, 2, 3, 4, 5]."
I have tried i <= 5, still not work

Your code so far

// Setup
const myArray = [];
for (let i = 0; i < 6; i++) {

// Only change code below this line

  **Your browser information:**

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

Challenge: Basic JavaScript - Iterate with JavaScript For Loops

Link to the challenge:

Hey! the problem seems to be on this line.

When the loop starts, the value of i would be 0 and in the next line you’re pushing 0 to the array which is not probably what you want.

When you’re dealing with loops, you should sprinkle a lot of console.logs in your code so you can actually see what the values of different variables are.

Hope this helps!:smile:

how do you sprinkle the console.log for each number ?

I meant you can use console.log statements in different parts of your program to see what values you get. for example, try adding console.log(i) inside of the for loop.

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