setTimeout

  • How do you make something happen after a specific delay?
  • Or maybe make something happen every 5 seconds?
function logHello() {
    console.log("Hello")
}

setTimeout(logHello, 3000); // Logs "Hello" in 3000 ms (3 sec)
setInterval(logHello, 5000); // Logs "Hello" _every_ 5000 ms (5 sec)

8 / 21