Tell us what’s happening:
Describe your issue in detail here.
**Your code so far**
// Setup
const myArray = [];
// Only change code below this line
let i = 6;
while (i < 6) {
myArray.push(i);
i--;
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36
Challenge: Iterate with JavaScript While Loops
Link to the challenge:
udaaff
2
This loop executes while i < 6
(less than 6) and you have let i = 6;
okay. Then what can I do to correct it?
ILM
4
what’s the first value you want your i to be, and what’s the last value?
ILM
6
is that the first or the last value?
ILM
8
And what should be the last value?
I think it’s like zero (0).
ILM
10
So you need to start at the first value you want, that will be the starting value you give toi
And then you need a loop that will be entered wit that value, and stop once your final value is reached
You need the right condition that will be true for 5,4,3,2,1,0 but not true for lower numbers
system
Closed
11
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.