While loop solution is wrong?

Tell us what’s happening:
The console.log for my proposed solution correctly displays [5,4,3,2,1,0], but the Run Test checker says that it’s wrong. Please explain
Your code so far


// Setup
//var myArray = [];
var ourArray = [];
// Only change code below this line
var i = 6;
while(i >0 ) {
ourArray.push(--i);
}
console.log(ourArray)
  **Your browser information:**

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

Challenge: Iterate with JavaScript While Loops

Link to the challenge:

the testers are checking for the value of myArray, which is undefined

myArray should equal [5,4,3,2,1,0] .

1 Like

You changed code above the line that says “Only change code below this line”.

1 Like

I changed from ourArray to myArray and it now works. Thx!

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