0Pricing
Javascript for Kids · Lesson

Repeating with while

Keep going while something is true.

Repeating with while 🔄

Hi, repeat ranger! 🌟 There is another loop called while!

It repeats while a rule is still true. 🪄

let i = 1
while (i <= 3) {
  console.log(i)
  i++
}

While It Is True ✅

while keeps going AS LONG AS the rule is true.

When the rule becomes false, it stops! 🛑

let count = 0
while (count < 3) {
  console.log("Loop! 🔁")
  count++
}

All lessons in this course

  1. Why We Use Loops
  2. Counting with a for Loop
  3. Repeating with while
  4. Drawing Patterns with Loops
← Back to Javascript for Kids