We make decisions in everyday life based on conditions.
If we’re tired, we might take a rest. If we’re thirsty, we would find something to drink. If we’re hungry, we grab something to eat. And if we want to be one with emojis 🧘♀️, we learn Emojicode.
We can mimic the same type of decision making in our code using conditionals. Conditionals take an expression, which is code that evaluates to determine a value, and checks if it is
👍, we can tell our program to do one thing — we can even account for
👎 to do another.
As we write more complex programs, conditionals allow us to address multiple scenarios and make our programs more robust.
If you’re ready, click Next.