# Race Day -

Hello All,

May i know why here in the Race Day project, all the adult runner number turns out to be += 1000 hence the running time all starts at 9:30.

I already put “else if” for condition (runnerAge>18 && !registeredEarly), why that runner late has been neglected in console.log? Thanks!

1 Like

Hi @chloeoscar,

you declared two variables:

``````const registeredEarly = true;
const runnerAge = 20;
``````

So, in this case condition `(runnerAge>18 && registeredEarly)` returns `true`. Try to change `registeredEarly` or `runnerAge` to see another log.

I am getting confused in the if else loop …can you help me …i am getting an error :–

let raceNumber = Math.floor(Math.random() * 1000);

let registeredTime = true;

let runnersAge =19;

if (runnersAge > 18 && registeredTime == true)
{
raceNumber += 1000;
}
if(runnersAge >18 && registeredTime == true)
{
console.log(`\${raceNumber} Your race will start at 09:30 AM`);
}
else if (runnersAge >18 && registeredTime == false)
{
console.log(`\${raceNumber} Your Race will start at 11:00 AM`);
}
else if
{
console.log(“Run at 12:00”);
}

else if {
console.log(“Report to registration desk”)
}

I am def not skillful enough to answer, hope someone can come and answer you!

and welcome to here!

@chloeoscar,
You need to start with the true argument on the left, you need to switch and declare registerEarly = true &&…
try to group your control flows better, I create different control flow for the <18 (1) and the >18 late and early(1 if, 1 else if). the = 18 I had an issue on my code as the log appears when i run the code with <18s

you forgot backtick ` bro and you don’t have a condition to your if else statement.
hope it helps.

there is also mistake in the last statement as instead iof elseif there shuld only be else,we end else if by else and also after registration desl) there should be a semicolon.

Code:

``````let raceNumber = Math.floor(Math.random() * 1000);
let registeredEarly = true;
let age = 30;

if (age > 18 && registeredEarly === true) {
raceNumber += 1000;
}
if (age > 18 && registeredEarly === true) {
console.log(`Your race starts at 9:30am, and your race number is \${raceNumber}. Good luck!`);
} else if (age > 18 && registeredEarly === false) {
console.log(`Your race starts at 11:00am, and your race number is \${raceNumber}. Now go relax!`);
} else (age < 18) {
console.log(`Your race starts at 12:30pm, and your race number is \${raceNumber}. Have fun and best of luck!`);
}
``````

And Error:

``````} else (age < 18) {
^
SyntaxError: Unexpected token {
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
``````

Why does it not like the curly bracket after `else (if age < 18)` ???

2 Likes

duh

I figured it out. I was using an `else` keyword when I should’ve been using `else if`

My newbie roots are showing.

1 Like

Yeah. Just noticed it and had to write but then noticed you just got it. Pretty good! Sometimes it’s just small things …

1 Like
``````let raceNumber = Math.floor(Math.random() * 1000);

const registeredEarly = false;

const runnerAge = 21;

if (runnerAge > 18 && registeredEarly) {
raceNumber += 1000;

}

if (runnerAge > 18 && registeredEarly) {
console.log(`You will race at 9:30 am and your race number is \${raceNumber}`);
} else if (runnerAge > 18 && !registeredEarly) {
console.log(`You will race at 11:00 am and your race number is \${raceNumber}`);
} else if (runnerAge < 18) {
console.log(`You will rune at 12:30 pm and your race number is \${raceNumber}`);
} else if (runnerAge === 18) {
}

this is my code and it seemed to work.
``````

let registeredLate = false;

let runnersAge = 19;

let raceNumber = Math.floor(Math.random()*1000);

if(registeredLate === true){

raceNumber += 1000;}

if(raceNumber > 1000 && runnersAge > 18){

console.log(`you will race at 9:30 am with the number \${raceNumber}`);

} else if(raceNumber < 1000 && runnersAge > 18){

console.log(`you will race at 11 pm with the number \${raceNumber}`);

} else if(raceNumber < 1000 && runnersAge < 18) {

console.log(`you will race at 12.30 pm with the number \${raceNumber}`);

} else {

}

you should not write the condition against the else it wont work remove that condition and your code will work

try this

let raceNumber = Math.floor(Math.random() * 1000);

let registeredEarly = false;

let age = 10;

if (age > 18 && registeredEarly === true) {

raceNumber += 1000;

if (age > 18 && registeredEarly === true) {

console.log(`Your race starts at 9:30am, and your race number is \${raceNumber}. Good luck!`);

} else if (age > 18 && registeredEarly === false) {

console.log(`Your race starts at 11:00am, and your race number is \${raceNumber}. Now go relax!`);

} else {

console.log(`Your race starts at 12:30pm, and your race number is \${raceNumber}. Have fun and best of luck!`);

}

}

else{

console.log(‘sorry’);

}

//random racenumber

let raceNumber = Math.floor(Math.random() * 1000);

//boolean registered early or not

const registeredEarly = true;

//runner’s age

const runnerAge = 21;

//condition to add 1000 if use registered early

if (runnerAge > 18 && registeredEarly) {

raceNumber += 1000;

}

// different other conditions

if (runnerAge > 18 && registeredEarly) {

console.log(`You will race at 9:30 am and your race number is \${raceNumber}`);

} else if (runnerAge > 18 && !registeredEarly) {

console.log(`You will race at 11:00 am and your race number is \${raceNumber}`);

} else if (runnerAge < 18) {

console.log(`You will run at 12:30 pm and your race number is \${raceNumber}`);

} else if (runnerAge === 18) {

}

HEEEEEEEEEELP!!! RACE DAY

let raceNumber = Math.floor(Math.random() * 1000);

let registeredEarly = false;

var runnerAge = 29;

if (runnerAge > 18 && registeredEarly) {

raceNumber+=1000}

{console.log(`You will race at 9:30 am. Your number is \${raceNumber}.`);

} if (runnerAge > 18 && !registeredEarly) {

console.log(`Late adults will race at 11:00 PM. Your number is \${raceNumber}.`);

} else if (runnerAge < 18) {

console.log(`Youth registrants run at 12:30 PM (regardless of registration).`);

}

else if (runnerAge === 18) {

}

I have some error:

1. When I change the values registeredEarly to false and runnerAge to above 18, I get this two response:
You will race at 9:30 am. Your number is 64.