Race Day Project

Hello Everyone! I am currently doing the Conditionals project for JAVASCRIPT = ‘RACE DAY’
Everything works when I run the code except the ${runnerNumber} does not show a number… it is just repeating these characters. I have the same issue with the Magic Eight ball project. Here is my code:

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

let registeredEarly = True;

let runnerAge = 20;

if (registeredEarly && runnerAge > 18) {console.log(raceNumber += 1000)}

if(registeredEarly && runnerAge > 18) {console.log(‘You will race at 9:30am. Your race number is: ${raceNumber}’)}

else if (!registeredEarly && runnerAge > 18) {console.log(‘You will race at 11:00am. Your race number is: ${raceNumber}’)}

else if (runnerAge < 18) {console.log (‘You will race at 12:30pm. Your race number is ${raceNumber}’)}

When I run this code, it says: You will race at 9:30am. Your race number is: ${raceNumber}

Where did I go wrong?

Thanks.

If you’re coming from python you have to remember that true is always lower-cased in js.

Welcome to the forums :slight_smile:
Remember organization is key. When posting here, especially for these errors it helps to format with the </> button. With just a little bit of clean up your code reads like this:

1377
You will race at 9:30am. Your race number is: 1377

You just have to double check your curly braces (along with that spelling of true).

Thanks for the tip! But I am still not getting a value for ${}

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

let runnerAge = 20;

if (registeredEarly && runnerAge > 18) 
  {console.log(raceNumber += 1000)}

if(registeredEarly && runnerAge > 18) 
  {console.log('You will race at 9:30am. Your race number is: ${raceNumber}')}

else if (!registeredEarly && runnerAge > 18)    
  {console.log('You will race at 11:00am. Your race number is: ${raceNumber}')}

else if (runnerAge < 18) 
  {console.log ('You will race at 12:30pm. Your race number is ${raceNumber}')}

else  {console.log ('You will see the registration desk')}

I’m not sure what I am doing wrong. When I run the code it’s still:

You will race at 9:30am. Your race number is: ${raceNumber}
1 Like

use ` instead of ’ . Example:

console.log(`${raceNumber}`)
console.log('${raceNumber}')

I didn’t notice earlier because before you formatted, the ` and ’ are indistinguishable.

it works! Thanks a lot ! :smiley: