Magic Eight Ball Project

I got stuck on the first part of the Magic Eight Ball project. This is the code I wrote:

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

I don’t understand why there is an error. According to my understanding, if the username equals ‘Jane’, then it should print ‘Hello, Jane’. If the username said ‘John’, then it should print just a simple ‘Hello’. Once I changed the code to match the tutorial, the program worked. I don’t understand why mine doesn’t work either, shouldn’t both of them work?

Hi @digital1249963027
since the code you posted here wasn’t formatted correctly, its not possible to see if there is a syntax error. But I assume that the hyphens and backticks are set correctly and the ternary operator works fine.
I remember that the exercise expected that the program prints any name that was assigned to userName and just print ‘Hello’ if no name was assigned to it. Maybe that’s why the program doesn’t accept your solution.

What’s the error you are seeing? That should tell you the line number and point with a ^ to where it thinks the error is.

At a guess, I would like at your first console.log — your quote makes it look like you are telling the computer that you want it to print out a variable called Hello, rather than a string.

Thanks guys, I figured it out. The error code pointed to the line where I formatted it incorrectly. Thanks for the tips!