Decisions with If/Else Statements
Learning Objective
I can write code using "if/else" statements to make decisions in JavaScript.
Key Concepts
An `if` statement in JavaScript starts with the keyword if, followed by a comparison in parentheses, and code to execute in curly brackets.
If the condition in an `if` statement is not true, an else statement can be used to execute alternative code.
The `else if` statement lets you check multiple conditions in a sequence, executing the code block for the first condition that evaluates to true.
Practice Questions
This lesson includes 10 practice questions to reinforce learning.
View questions preview
1. What keyword is used to start an 'if' statement in JavaScript?
2. Explain the purpose of the 'else' statement in relation to an 'if' statement.
3. In JavaScript, what is the correct syntax for an 'if' statement?
...and 7 more questions
Educational Video
Learn JavaScript Episode #7: If/Else Statements
Joseph Delgadillo