0Pricing
Javascript for Kids · Lesson

Play Again

Loop the game.

Play Again is a free Javascript for Kids lesson on CoddyKit — lesson 4 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.

One Game Is Not Enough! 🔁

One round is fun, but who wants to play just once? Nobody! 😄

Let's make the game play again and again using a loop! 🔄

console.log('Round 1! 🎮')
console.log('Round 2! 🎮')
console.log('Round 3! 🎮')

What is a Loop? 🌀

A loop repeats code many times so you don't have to copy-paste! 🌀

Imagine telling your robot "do this 5 times" instead of saying it 5 times. 🤖

console.log('A loop repeats things! 🔁')
console.log('Super handy! ✨')

The for Loop 🔢

A for loop counts for us! 🔢

It starts at a number, keeps going while a rule is true, and adds 1 each time.

for (let i = 1; i <= 3; i++) {
  console.log('Count: ' + i + ' 🔢')
}

Playing 3 Rounds 🎮

Let's use the loop to play 3 rounds of the game! 🎮

Each time through, it's a new round. 🔄

for (let round = 1; round <= 3; round++) {
  console.log('--- Round ' + round + ' ---')
  console.log('Playing! 🎲')
}

Adding the Picks 🤖

Inside each round, the computer makes a fresh pick! 🤖

Let's add our random picker to the loop. 🎲

let choices = ['rock', 'paper', 'scissors']
for (let round = 1; round <= 3; round++) {
  let comp = choices[Math.floor(Math.random() * 3)]
  console.log('Round ' + round + ': computer picked ' + comp + ' 🤖')
}

Keeping Score 🏅

Let's count how many times you win! We make a score box and start it at 0. 🏅

Each win adds 1!

let score = 0
score = score + 1
score = score + 1
console.log('Your score: ' + score + ' 🏅')

Score Inside the Loop 📈

Now we keep score across all the rounds! 📈

The score box remembers wins from round to round. 🧠

let score = 0
for (let round = 1; round <= 3; round++) {
  score = score + 1
  console.log('Round ' + round + ': win! Score = ' + score + ' 🏅')
}

The while Loop 🔄

Another loop is the while loop. It keeps going while something is true! 🔄

Great for "keep playing until 3 wins". 🎯

let wins = 0
while (wins < 3) {
  wins = wins + 1
  console.log('Win number ' + wins + '! 🎉')
}
console.log('Got 3 wins! 🏆')

Stop the Loop 🛑

Sometimes we want to STOP early. We use break to jump out of the loop! 🛑

Like stopping the game when someone wins big. 🏆

for (let i = 1; i <= 10; i++) {
  console.log('Round ' + i)
  if (i === 3) {
    console.log('Game over! 🛑')
    break
  }
}

The Full Game Loop 🎉

Let's put it ALL together: loop, computer pick, and score! 🎉

This is your very own Rock Paper Scissors game! 🕹️

let choices = ['rock', 'paper', 'scissors']
let score = 0
for (let round = 1; round <= 3; round++) {
  let comp = choices[Math.floor(Math.random() * 3)]
  console.log('Round ' + round + ': computer ' + comp)
  score = score + 1
}
console.log('Final score: ' + score + ' 🏆')

You Built the Whole Game! 🕹️

Incredible! You made a full game that plays again and again! 🎉

  • for loop counts rounds 🔢
  • while loop keeps going 🔄
  • break stops early 🛑
  • A score box keeps points 🏅
console.log('You built the game! 🕹️')
console.log('You are a coder! 🌟')

Quick Check 🧠

Last brain question! 🤔

You Did It! 🎉

You finished the Rock, Paper, Scissors game! 🥳

  • Learned the rules ✊📄✂️
  • Made the computer pick 🤖
  • Found the winner 🏆
  • Looped to play again 🔁

You are a real game maker! 🌟 Great job!

console.log('Course complete! 🎓')
console.log('You rock! 🤘')

Frequently asked questions

Is the “Play Again” lesson free?

Yes — the full text of “Play Again” 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 “Play Again”?

Loop the game. 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 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Play Again” 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. The Rules
  2. Computer Picks
  3. Who Wins?
  4. Play Again
← Back to Javascript for Kids