🧮 Operators in Action

ARITHMETIC

= 10

Try different numbers and operators! The % (modulo) gives the remainder.

⚖️

COMPARISON

= true
⚠️

THE TRAP: = vs ===

ASSIGNMENT (changes value!)

score = 100

"score GETS 100"

COMPARISON (checks value)

score === 100

"Is score equal to 100?"

🛠️

HELPER FUNCTIONS

randomBetween(min, max)
Returns a random whole number between min and max (inclusive). Great for unpredictable values like daily challenges or dice rolls.
Robot ID Card uses: randomBetween(1, 10) for Challenge Level
?
coinFlip()
Returns true or false randomly (50/50 chance). Like flipping a coin—useful for random yes/no decisions.
Example: const isLucky = coinFlip();
?
choose(condition, ifTrue, ifFalse)
Picks between two values based on a condition. If condition is true, returns the second parameter. If false, returns the third.
Robot ID Card uses: choose(energyLevel > 50, "Energized!", "Need rest...")
choose( true , "Energized!" , "Need rest..." )
Toggle condition: "Energized!"
Condition is true, so we return the second parameter.

🟠 HAP's Insight: These operators and helpers power the Robot ID Card! energyLevel - 15 drains energy, energyLevel > 50 checks my mood, and randomBetween(1, 10) generates daily challenges.

← Back to Station 5