JS Built-ins
ControlFlowintermediate

Control Flow β€” break and continue

break exits the loop, continue skips the iteration

  • break exits the nearest enclosing loop immediately
  • continue skips to the next iteration

Challenge: Write filterAndStop(arr, skipVal, stopVal) that:

  • Skips elements equal to skipVal (continue)
  • Stops collecting when it hits stopVal (break)
  • Returns all collected elements
πŸ’‘ Hints (1)
  • β€’ Check stopVal BEFORE skipVal so break takes priority