Make Decisions
Control logic flow with branching.
We'll cover the following...
We'll cover the following...
Now that JavaScript can remember things, let’s teach it to think—by making decisions with if, else if, and else logic!
Goal
You will learn to:
Use
if,else if, andelseto make decisions.Compare values with
===,>,<, etc.React differently based on input or data.
Use if to choose what happens
In JavaScript, there are conditional statements that work by checking if something is true, and then deciding what to do based on that. If the condition is true, the code inside the block runs. If not, it checks the next condition—or runs the default else.