0
Can we use continue in the block of while loop?
Why this code not working: let I = 7; while (I) { if (I==3) continue; console.log(i—); }
8 Antworten
+ 3
Like this
let i = 7;
while(i > 0) {
if(i == 3) {
continue;
}
console.log(i--);
}
+ 2
After the i is a line and not 2 minuses (--)
and another reason can be that you use capital I and lowercase i
+ 1
Also I think it isn't neccessary, but you should put the "continue" statement into { }.
+ 1
Yep, it should work now. 👍
+ 1
issue is continue will go back to the while loop and ‘i’ will never get to decrement, should be
let i = 7;
while(i==3) {
i—;
continue;
}
console.log(i—);
}
✌🏻
0
Hm, I was fast with confirming this is working, runinig in WebStorm to Chrome and still getting Page uresponsive error
0
You should use for cycle instead.
for (let i = 7; i > 0; i--)
{
if (i == 3){continue;}
console.log(i);
}
0
agree, I just confused why it not working with while solution is need to use decrement two times