0Pricing
Javascript for Kids · Lesson

Heads or Tails

Random coin flip.

Welcome to Coin Flip! 🪙

Hi there, coder! 👋 Today we are going to build a Coin Flip Game! 🪙

When you flip a real coin, it lands on Heads or Tails. We never know which one will come up. That is what makes it fun! 🎉

Let's teach the computer to flip a coin too!

What is Random? 🎲

A coin flip is random. Random means we cannot guess the answer for sure. 🤷

JavaScript has a special helper called Math.random(). It gives us a surprise number between 0 and 1. 🎲

Let's see what it gives us!

console.log(Math.random());
console.log(Math.random());
console.log(Math.random());

All lessons in this course

  1. Heads or Tails
  2. Guessing
  3. Checking the Guess
  4. Flip Many Times
← Back to Javascript for Kids