Ready. Start with one instruction.
Loading the learning workspace…
FROM YOUR FIRST INSTRUCTION TO A WORKING APPLICATION
Learn JavaScript from scratch through small working examples, visual experiments and complete projects. No account or AI key required.
Predict → Experiment → Build → Test → Explain
Ready. Start with one instruction.
Loading the learning workspace…
continue skips the remainder of the current loop body and proceeds to the next iteration. break exits the loop entirely. They affect control flow, so place them near the condition they express. This example skips even values while keeping later odd ones. Replacing continue with break would stop at the first even number and lose valid later values.
const end = 5;
for (let i = 1; i <= end; i++) {
if (i % 2 === 0) continue;
console.log(i);
}1 3 5
The even value is skipped, but the loop continues and can still print later odds.
const end = 5;Declare end with const. The binding cannot be reassigned. The expression after = supplies its initial value; = is assignment, not an equality comparison.
for (let i = 1; i <= end; i++) {Initialize the counter once, test its condition before each iteration, and update it after the body. Track the boundary carefully.
if (i % 2 === 0) continue;Choose a branch according to this condition. Only the selected path runs for this input; inspect the exact comparison and its boundary.
console.log(i);Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
}Close the current instruction block.
const end = 2;
for (let i = 1; i <= end; i++) {
if (i % 2 === 0) continue;
console.log(i);
}1
The even value is skipped, but the loop continues and can still print later odds.
const end = 2;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
for (let i = 1; i <= end; i++) {Initialize the counter once, test its condition before each iteration, and update it after the body. Track the boundary carefully.
if (i % 2 === 0) continue;Choose a branch according to this condition. Only the selected path runs for this input; inspect the exact comparison and its boundary.
console.log(i);Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
}Close the current instruction block.
const end = 1;
for (let i = 1; i <= end; i++) {
if (i % 2 === 0) continue;
console.log(i);
}1
The even value is skipped, but the loop continues and can still print later odds.
const end = 1;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
for (let i = 1; i <= end; i++) {Initialize the counter once, test its condition before each iteration, and update it after the body. Track the boundary carefully.
if (i % 2 === 0) continue;Choose a branch according to this condition. Only the selected path runs for this input; inspect the exact comparison and its boundary.
console.log(i);Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
}Close the current instruction block.
Repair the intentionally changed operation so the example produces the exact expected result. Then try the extension without copying the answer.
const end = 5;
for (let i = 1; i <= end; i++) {
if (i % 2 === 0) break;
console.log(i);
}const end = 5;
for (let i = 1; i <= end; i++) {
if (i % 2 === 0) continue;
console.log(i);
}Choose break when the entire search is finished, not when only one item should be ignored.
Which operation changed the result, why did it work, and what would you test next?
Use a different value that could expose a boundary or mistake. Predict the result first, run it, and explain how the concept would help in a small real application.
Related: Previous lesson Next lesson
100 lessons across 20 modules, covering variables, operators, strings, conditions, loops, functions, scope, arrays, objects, DOM, events, state, testing, asynchronous JavaScript and application development.