else if Statements, online
Six activities your students do on their own devices. See who's finished, and their scores.
else if Statements in one minute
What students need to know
else if is exactly how you check another condition. As soon as one condition is true, the rest are skipped.
'else if' must be written as two separate words with a space. You can have as many else if blocks as needed in a chain.
Mistakes students make
- 'else if' needs a space - 'elseif' is not valid syntax.
- 'else' must be lowercase - a capital E causes an error.
- 'if' must be lowercase - a capital I causes an error.
- The else if condition needs an opening parenthesis.
What students will learn in this module
Every question in Module 15
Quick questions
- Does else if check another condition when the first if was false?ANoBYes
- Is 'elseif' with no space valid JavaScript syntax?ANoBYes
- Can you chain multiple else if blocks together?AYesBNo
- Does else if need its own condition in parentheses?ANoBYes
- Will only one block in an if/else if chain run?AYesBNo
Key terms
Students type the meaning of:
else if
Match the pairs
} else if (score >= 70) { ... }Match it to what it does} else if (age < 18) { ... }Match it to what it doesAdds another condition to check after an ifMatch it to what it doesOnly one block in a chain of these runsMatch it to what it does} elseif (score >= 70) { ... }Match it to what it does} Else if (age < 18) { ... }Match it to what it doesFill in the blanks
} _______ (score >= 70) {Hint: Type the two keywords that check another condition after if.
if (age < 13) { } else if (age < __) {Hint: Type the age value used in the second condition.
if (n === 1) { } else if (n === _) {Hint: Type the number checked in the second condition.
} else __ (temp > 30) {Hint: Type the keyword that comes after 'else' to check another condition.
} ____ if (level === 2) {Hint: Type the keyword that comes before 'if' to check another condition.
Spot the error
Question 1
A} elseif (score >= 70) {Bif (score >= 90) {C}
Question 2
Aif (age < 13) {B} Else if (age < 18) {C}
Question 3
Aif (n === 1) {B}C} else If (n === 2) {
Question 4
Aif (temp > 30) {Bconsole.log("Hot");C}D} else if temp > 20) {
Question 5
Aif (level === 1) {B} else if (level === 2 {Cconsole.log("L1");D}
