Day 3: Timers (setTimeout & setInterval)
Daily Objective
Section titled “Daily Objective”Schedule deferred and recurring code execution with browser timers.
1. Timers
Section titled “1. Timers”// setTimeout: runs once after delayconst timeoutId = setTimeout(() => { console.log('Executed after 2 seconds');}, 2000);
// setInterval: runs continuously every intervallet count = 5;const intervalId = setInterval(() => { console.log(count); count--; if (count === 0) clearInterval(intervalId); // stops timer}, 1000);Daily Hands-on Practice (70%)
Section titled “Daily Hands-on Practice (70%)”- Build a functional stopwatch with Start, Stop, and Reset buttons.