0Pricing
Javascript for Kids · Lesson

Waiting with setTimeout

Pause between numbers.

Waiting with setTimeout is a free Javascript for Kids lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Javascript for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Wait For It... ⏱️

A real countdown waits one second between numbers! We use setTimeout to make the computer wait. ⏱️

console.log('Let us learn to wait! ⏱️')

What Is setTimeout? ⏰

setTimeout runs some code AFTER waiting a number of milliseconds. 1000 ms = 1 second! ⏰

setTimeout(function () {
  console.log('One second passed! ⏰')
}, 1000)

Milliseconds 🕐

Time is measured in milliseconds. 1000 ms is 1 second, 2000 is 2 seconds. 🕐

setTimeout(function () {
  console.log('Two seconds! 🕐')
}, 2000)

Wait Then Speak 💬

Let's print something now, then something else after waiting. 💬

console.log('Starting now... ⏳')
setTimeout(function () {
  console.log('Done waiting! ✅')
}, 1000)

The Waiting Function 📦

The code inside setTimeout is a function. It waits patiently until time is up! 📦

setTimeout(function () {
  console.log('Surprise! 🎁')
}, 1500)

Two Timers 2️⃣

We can set more than one timer, each with its own wait time! 2️⃣

setTimeout(function () {
  console.log('First! 1️⃣')
}, 1000)
setTimeout(function () {
  console.log('Second! 2️⃣')
}, 2000)

Counting With Waits 🔢

We can show numbers one second apart by giving each its own timer. 🔢

setTimeout(function () { console.log(3) }, 1000)
setTimeout(function () { console.log(2) }, 2000)
setTimeout(function () { console.log(1) }, 3000)

Meet setInterval 🔁

setInterval repeats code over and over with a wait between each time! 🔁

setInterval(function () {
  console.log('Tick! ⏱️')
}, 1000)

Stopping a Timer 🛑

We can stop a repeating timer with clearInterval so it doesn't go forever! 🛑

let count = 0
let timer = setInterval(function () {
  count++
  console.log(count)
  if (count === 3) clearInterval(timer)
}, 1000)

Countdown With Interval ⬇️

Let's count down using setInterval, one number each second! ⬇️

let i = 3
let timer = setInterval(function () {
  console.log(i)
  i--
  if (i < 0) clearInterval(timer)
}, 1000)

Full Waiting Demo 🎮

Here is a countdown that waits one second between each number! 🎮⏱️

let i = 5
let timer = setInterval(function () {
  console.log(i + '...')
  i--
  if (i < 0) {
    clearInterval(timer)
    console.log('Time is up! ⏰')
  }
}, 1000)

Quick Check ✅

Test your timer skills! 🧠

Timer Wizard! 🌟

Great job! You learned to wait with setTimeout! 🎉

  • 1000 ms = 1 second ⏰
  • setInterval repeats 🔁
  • clearInterval stops it 🛑

Next: blast off! 🚀

console.log('Waiting with timers: LEARNED! 🌟')

Frequently asked questions

Is the “Waiting with setTimeout” lesson free?

Yes — the full text of “Waiting with setTimeout” is free to read here on the web, and the Javascript for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Javascript for Kids course, upgrade to CoddyKit PRO.

What will I learn in “Waiting with setTimeout”?

Pause between numbers. You practise Javascript for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Javascript for Kids?

No prior experience is required. Javascript for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Waiting with setTimeout” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Javascript for Kids lesson?

Yes. Every Javascript for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Counting Down to Zero
  2. Waiting with setTimeout
  3. Blast Off!
  4. Your Own Timer
← Back to Javascript for Kids