Conditionals let a program make decisions. Depending on whether a condition is true or false, the program takes one path or another.
Without conditionals, a program runs the same code every time. With conditionals, it can respond differently based on data — a player’s choice, a score, an input value.
Types of Conditionals#
If/Else Statement#
The most common conditional. Checks a condition and runs one block of code if it’s true, another if it’s false.