Basic JavaScript - Iterate with JavaScript While Loops

the code doesnt work in here but it works and does what it needs when i compile the code in visual studio.
this is the output i am getting: [ 5, 4, 3, 2, 1, 0 ]

// Setup
const myArray = [ ];
// Only change code below this line
i = 5;
while(i >= 0) {
  myArray.push(i);
  i--;
}
1 Like

I am assuming it’s this challenge?

If it is that challenge, look at the instructions again, you aren’t doing what it’s asking

1 Like

:balloon:Hello @lordas156 ! Welcome to the forum!

I’m not really sure what your question is, but the code posted definitely produces the output [5,4,3,2,1,0].

Does this help?
Keep up the good progress!

Happy Coding! :slightly_smiling_face:

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