Stuck on else statement

Hi all, I’m working on:

I’ve gotten to the last line of code and the code editor is telling my I have an invalid { included and I can’t for the life of me figure out why it’s wrong.

Here’s the code:

if (runnerAge > 18 && earlyRegistry === true) {
  console.log(`Your race start time is 9:30am and your number is ${raceNumber}.`);
} else if (runnerAge > 18 && earlyRegistry === false) {
  console.log(`Late adults run at 11:00am. Your number is ${raceNumber}.`);
} else if (runnerAge < 18) {
  console.log(`Youth registrants run at 12:30pm. Your race number is ${raceNumber}.`);
} else (runnerAge = 18) {
  console.log(`Please see the registration desk.`);

The last else statement keeps throwing back an error. Help!

Hey, welcome to the forums! :wave:

Unlike an if or else if statement, an else statement cannot take a condition to evaluate, as it’s designed to be a catch-all for if no conditionals match. You would have to remove the conditional (runnerAge = 18).

On a side note, be careful with = vs == or ===. A single equals is used for assignment, while you want the two or three for a comparison.

Happy coding! :slight_smile:

Ahh, sweet, tks that makes sense!

1 Like