Eight Ball Formatting issue

So I am at the beginning of the Magic Eight Ball JavaScript and I am failing to see why what I have typed is not reading correctly.

This is on step 2: " create a ternary expression that decides what to do if the user enters a name or not. If the user enters a name — like 'Jane' — use string interpolation to log Hello, Jane! to the console. Otherwise, simply log Hello! ."

Here is what I have typed:

let userName = ‘Jane’;

userName ? console.log (‘Hello, ${userName}!’) : console.log(‘Hello!’);

When I save it prints: “Hello, ${userName}!” instead of the expected “Hello, Jane!”

I looked at the video and the hint and it is identical:

userName ? console.log(Hello, ${userName}!) : console.log(‘Hello!’);

Is this an error on the system’s part or am I missing something in my code? I am not seeing the difference when I compare what I type and what I can copy/paste from the hint. (Just want to be sure I’m not missing something on my part in my learning process.) Thanks!

EDIT: The same is happening when I try to go into the next steps writing:

const userQuestion = ‘Will I pass my test?’;

console.log(‘${userName}, you asked ${userQuestion}’)

If you don’t have a string interpolation I would not suggest using the backticks to save a value to a variable which in your case is just a simple string.

instead of basically declaring the variable userName with

userName = ‘Jane‘

save it as a regular string

userName = “Jane”.

Based on the code you have posted, it appears you aren’t using backticks for string interpolation.
Make sure you are using backticks (the key with the tilde ~. It is next to the 1 key on US Qwerty keyboards in the top left corner) for string interpolation:

// Backticks: correct

// Quotes (single or double): incorrect
1 Like

Thank you! It was an issue of forgetting the back ticks. I was reading the back ticks as a single quotes and wasn’t seeing the difference. I think that will clear up my difference.

1 Like