Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
JAVASCRIPT TEXT / CHAPTER 03 / Learn / LESSON 05
Fifth class. while repeats a block while the condition is true. Update the counter inside — or the loop never stops.
break exits the loop immediately. continue skips the rest of the current turn and goes to the next condition check.
Mini example:
let n = 3; while (n >= 1) { if (n === 2) { n = n - 1; continue; } console.log(n); if (n === 1) break; n = n - 1; }
Common mistake: forgetting to change n; or putting break/continue outside a loop.
continue skips 3; break stops after 1.
DATA STANDBY
›