0

JS how can I ‘continue’ array of items, if i == the array....

————————————- var rmv = [3, 7]; var i = 0; for (i = 0; i < 10; i++){ if(i == rmv[3]){ continue; } console.log(i) } —————————————— So, if i == 3, or 7, continue. I could do it using if (i == 3 || if I == 7){ continue; } I’m observing if there is a shorter way to do it _ like a loop maybe like I started it_ https://code.sololearn.com/W7OL5iBRnfbQ/?ref=app

21st Apr 2020, 11:17 PM
Ready To Learn
Ready To Learn - avatar
2 odpowiedzi
+ 1
Try this: var rmv = [3, 7]; var i = 0; for (i = 0; i < 10; i++){ if(rmv.includes(i)){ continue; } console.log(i) }
21st Apr 2020, 11:32 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
@ChalticDawg That works. Thanks.
21st Apr 2020, 11:45 PM
Ready To Learn
Ready To Learn - avatar