else Statements, online

Six activities your students do on their own devices. See who's finished, and their scores.

else Statements in one minute

What students need to know

else is exactly what catches every remaining case. Unlike if and else if, else never takes a condition.

else acts as the fallback when nothing else matched. JavaScript is case-sensitive, so 'else' must be lowercase.

Mistakes students make

  • 'else' must be lowercase - a capital E causes an error.
  • else never takes a condition in parentheses.
  • 'else' is misspelled as 'els'.
  • Code blocks use curly braces {}, not square brackets [].

Discover other journeys with this module

What students will learn in this module

Every question in Module 16

Quick questions

  1. Does else run when every earlier condition was false?ANoBYes
  2. Does else have its own condition in parentheses?ANoBYes
  3. Must 'else' be written in lowercase?AYesBNo
  4. Can else come before an if statement in a chain?ANoBYes
  5. Does else's code block use curly braces?ANoBYes

Key terms

Students type the meaning of:

  • else

Match the pairs

} else { ... }Match it to what it does
if (score >= 70) { ... } else { ... }Match it to what it does
Acts as the final fallback in a conditional chainMatch it to what it does
Has no condition of its ownMatch it to what it does
} Else { console.log("Fail"); }Match it to what it does
} else (age < 18) { ... }Match it to what it does

Fill in the blanks

  1. } ____ {

    Hint: Type the keyword used as the final fallback branch.

  2. if (age >= 18) {
    } ____ {
    console.log("Minor");
    }

    Hint: Type the keyword used as the final fallback branch.

  3. if (n === 1) {
    } ____ {
    console.log("other");
    }

    Hint: Type the keyword used as the final fallback branch.

  4. if (temp > 30) {
    } ____ {
    console.log("Cool");
    }

    Hint: Type the keyword used as the final fallback branch.

  5. if (isOpen) {
    } ____ {
    console.log("Closed");
    }

    Hint: Type the keyword used as the final fallback branch.

Spot the error

Question 1

Aif (score >= 70) {B} Else {Cconsole.log("Fail");D}

Question 2

Aif (age >= 18) {B} else (age < 18) {Cconsole.log("Minor");D}

Question 3

Aif (n === 1) {B} els {Cconsole.log("one");Dconsole.log("other");E}

Question 4

Aif (temp > 30) {Bconsole.log("Hot");C} else [Dconsole.log("Cool");E]

Question 5

Aif (isOpen) {Bconsole.log("Open");C} else {Dconsole.log("Closed")E}