DEV Community

Discussion on: problem with this Javascript code, im noob btw

Collapse
 
genspirit profile image
Genspirit

I don't use continue often but doesn't it break the loop iteration? Meaning that would lead to an infinite loop in the while example because i would not get incremented.

Collapse
 
mranyx profile image
MrAnyx

Yeah, i forgot that point, if you're using a while loop, you should increment i before the if statement. otherwise, it will create an infinite loop. If you're using a for loop, the code i wrote above is OK