When i write my code like this it works
if (runnerAge > 18 && earlyRegistration) {
console.log(Race starts at 9:30am - You're #${raceNumber}!
);
} else if (runnerAge > 18 && !earlyRegistration) {
console.log(Race starts at 11:00am - You're #${raceNumber}!
);
} else if (runnerAge < 18) {
console.log(Race starts at 12:30pm - You're #${raceNumber}!
);
}
//
else (runnerAge = 18)
console.log(See registration desk.
);
//
But when i write it like this it doesnt
if (runnerAge > 18 && earlyRegistration) {
console.log(Race starts at 9:30am - You're #${raceNumber}!
);
} else if (runnerAge > 18 && !earlyRegistration) {
console.log(Race starts at 11:00am - You're #${raceNumber}!
);
} else if (runnerAge < 18) {
console.log(Race starts at 12:30pm - You're #${raceNumber}!
);
}
//
else (runnerAge = 18) {
console.log(See registration desk.
);
}
//
I get an UNEXPECTED TOKEN ERROR for some reason with the second one. And no error with the first.
Yikes, that’s frustrating.
There are some things that need to be clarified first…
- Is this a bug with the course, or a bug in your code?
- Could you be a bit more descriptive with your post–please include link to lesson and include all your code if you haven’t already done so.
Also, maybe this would help with debugging:
My guess is I gave else a condition . Thats why it wont work. IDK
Either way, the last part of the conditional should be an else if, since there’s actually a conditional check being performed.
2 Likes