Race Day - calling the variable won't work?

I keep trying to call the variable raceNumber in my console.log, but it is not registering as a called variable. Anyone else having this issue? Can anyone see what I need to change in my code?

let raceNumber = Math.floor(Math.random() * 1000); let Early = true; let age = 19; if (Early && age > 18){ raceNumber += 1000; } if (Early && age > 18){ console.log('Race will begin at 9:30. Your race number is: ${raceNumber}.') }

The condition on line 8 is the same as that on line 5.

2 Likes

In addition to what mtf said, note how you’re using quotation marks for your strings? In order to use template literals, which is where one embeds a variable’s value into a string, you need back ticks:

let a = "world";
//not template literal:
console.log("hello ${a}");//prints: hello ${a}

//template literal:
console.log(`hello ${a}`);//prints: hello world
3 Likes

But I am using back ticks. The string in line 10 is enclosed in back ticks.

…nevermind. I was using inverted commas, not back ticks. Thank you!

1 Like