To be answered
Let's explore the different control flow statements in JavaScript and test the understanding with a quiz.
for (let i = 0; i <= 5; i++) { if (i === 3) { continue; } console.log(i); }
let i = 0; do { console.log(i); i++; } while (i < 3);
const value = null || "Default"; console.log(value);
let num = 5; const result = num && "Value exists"; console.log(result);
let num = 3; while (num > 0) { console.log(num); num -= 2; }
const value = "" || 0 || false || "Fallback"; console.log(value);
const a = 5; function foo() { if (a === 5) { let a = 10; } console.log(a); } foo();
let x = 0; while (x < 10) { if (x === 5) { break; } x++; } console.log(x);
let x = 2; let result = ''; switch (x) { case 1: result += 'A'; case 2: result += 'B'; case 3: result += 'C'; default: result += 'D'; } console.log(result);
Subscribe to our newsletter