0

How can I have continue work in my code?

https://code.sololearn.com/WV9g6Ip75juA/?ref=app I have a for loop in a function and a condition statement in another function. When calling the function with the condition statement, it works just fine - except when continue is used. I like to structure my code this way when I have a long for loop, but it becomes a problem when continue is needed for the functionality. If anyone has any insight into how continue can be made to work when it is inside another function, that would be greatly appreciated.

3rd Feb 2019, 11:05 PM
Thomas Czernek
Thomas Czernek - avatar
1 Odpowiedź
+ 1
you can do something like this instead. continue works only when there is an iteration. (a loop) window.onload = () =>{ const x = 5; const y = [0, 1, 2, 3, 4, 5]; const condition = (i)=>{ if(x !== y[i]){ return true ; } } const loop = () =>{ for(let i = 0; i < y.length; i++){ if(condition(i)){ alert('hello');} } } loop(); }
4th Feb 2019, 12:52 AM
Bahhaⵣ
Bahhaⵣ - avatar