🚧 施工中
Last updated 8 months ago
Was this helpful?
JS⟩ syntax ⟩ for loops ⟩ arr.forEach()
to skip a case, use return.
⭐️ there's no way to break/continue in this method❗️
💾 程式:replit
let array = [1, 2, 3, 4, 5]; // ⭐️ skip a case with `return` array.forEach(n => { if (n % 2 !==
replit:no break/continue in forEach()
let array = [1, 2, 3, 4, 5]; // ❌ can't use `break` in .forEach() array.forEach(n => { if (n % 2 !==
Using Continue in JavaScript forEach() - use return to skip a case
Array.prototype.forEach()
to do:
break statement
continue statement