New course! Every coder should learn Generative AI!
Try a free lesson+ 5
The code below outputs 2 and that's why I find it hard to read. Can someone be nice enough to explain plizzz?
var y=0; for(var x=0; x<3; x++) { if(x==2) { x=5; continue; } y++; } document.write(y);
5 Answers
+ 5
y will be incremented twice. When x is 0, and when x is 1. When x equals 2, x becomes 5, and then it continues, so y won't be incremented. x isn't smaller than 3, so the loop stops
+ 4
Oh, Airree thanks for the short and precise explanation, it helped
+ 1
Airee is right
0
Ismonix Boom Thank you for your contribution, but on sololearn you shouldn't really swear :/
- 1
fack you