If, Else If and Else Statements
Learn how to branch off based on conditional statements like if, else if and else statements.
We'll cover the following
The time has come when we can fit the puzzle pieces together. You have learned about different primitive and composite types. You know how to check these types. You know the basic functions and arithmetic (addition, subtraction, multiplication, etc.) and logical (true or false) operations in JavaScript.
There are only two things missing. So far, we can write a sequence of instructions that perform a calculation. In software development, there are three types of control structures:
- sequence: writing instructions one after the other
- selection: either execute one set of instructions, or another
- iteration: execute a set of instructions a finite or infinite number of times
As you already know how to sequence instructions one after the other, it is time to learn about selection and iteration. Let’s start with selection:
Get hands-on with 1200+ tech skills courses.