0Pricing
Javascript for Kids · Lesson

Who Wins?

Compare choices.

Time to Find the Winner! 🏆

You and the computer both made a pick. Now the big question: who wins? 🤔

We'll teach the code to compare the two picks! ⚖️

let you = 'rock'
let computer = 'scissors'
console.log('You: ' + you + ' ✊')
console.log('Computer: ' + computer + ' ✂️')

Check for a Tie First 🤝

The easiest check is a tie. If both picks are the same, nobody wins!

We use === to see if they match. 🟰

let you = 'paper'
let computer = 'paper'
if (you === computer) {
  console.log('It is a tie! 🤝')
}

All lessons in this course

  1. The Rules
  2. Computer Picks
  3. Who Wins?
  4. Play Again
← Back to Javascript for Kids