0Pricing
Javascript for Kids · Lesson

Picking an Operation

Choose with if.

Let the User Choose! 🎛️

A real calculator lets you PICK what math to do. Press +, or -, or ×!

To make choices in code, we use the magic word if. 🤔

What Is if? 🚦

if checks: is something TRUE? If yes, it runs the code inside its { }!

It is like a guard at a door who only lets you in IF you have a ticket. 🎟️

let op = 'add'
if (op === 'add') {
  console.log('You picked adding!')
}

All lessons in this course

  1. Two Numbers
  2. Doing Math
  3. Picking an Operation
  4. Showing the Answer
← Back to Javascript for Kids