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.
PREVIOUS · MODULE 14If Statements
YOU ARE HERE · MODULE 15else if Statements
NEXT · MODULE 16else Statements

Discover other journeys with this module

What students will learn in this module

Every question in Module 15

Quick questions

  1. Does else if check another condition when the first if was false?ANoBYes
  2. Is 'elseif' with no space valid JavaScript syntax?ANoBYes
  3. Can you chain multiple else if blocks together?AYesBNo
  4. Does else if need its own condition in parentheses?ANoBYes
  5. 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 does
Adds another condition to check after an ifMatch it to what it does
Only 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 does

Fill in the blanks

  1. } _______ (score >= 70) {

    Hint: Type the two keywords that check another condition after if.

  2. if (age < 13) {
    } else if (age < __) {

    Hint: Type the age value used in the second condition.

  3. if (n === 1) {
    } else if (n === _) {

    Hint: Type the number checked in the second condition.

  4. } else __ (temp > 30) {

    Hint: Type the keyword that comes after 'else' to check another condition.

  5. } ____ 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}