Day 4: Nested Loops & Classic Algorithms (FizzBuzz)
Daily Objective
Section titled “Daily Objective”Master nested iteration and implement classic logic patterns like multiplication grids and FizzBuzz.
1. Nested Loops (Multiplication Table)
Section titled “1. Nested Loops (Multiplication Table)”for (let table = 1; table <= 3; table++) { console.log(`--- Table of ${table} ---`); for (let num = 1; num <= 5; num++) { console.log(`${table} x ${num} = ${table * num}`); }}2. The Classic FizzBuzz Algorithm
Section titled “2. The Classic FizzBuzz Algorithm”Print numbers 1 to 100:
- Multiples of 3: Print “Fizz”
- Multiples of 5: Print “Buzz”
- Multiples of both 3 and 5: Print “FizzBuzz”
- Otherwise: Print the number
for (let i = 1; i <= 15; i++) { if (i % 3 === 0 && i % 5 === 0) { console.log('FizzBuzz'); } else if (i % 3 === 0) { console.log('Fizz'); } else if (i % 5 === 0) { console.log('Buzz'); } else { console.log(i); }}Daily Hands-on Practice (70%)
Section titled “Daily Hands-on Practice (70%)”- Write the full FizzBuzz challenge from 1 to 50 from memory.
- Build a checkerboard pattern in console using nested loops.