Help with simple Javascript problem

I am completing one of the very first questions for using Javascript in the console and I have tried this question many times and even the supplied solution doesnt work. This is the question with the solution:

and this is what I’ve tried recently. so you can see that the solution given does not work, and neither do my attempts yet the variables do contain the strings

image

I cant figure this one out on my own. any help would be appreciated!

1 Like

Hi @StorDreng,

As you can see in the solution the apostrophe used are different for string outputs.

You are using a single tick/single quotes symbol --> ' my normal string stynax ' . But if you want to have the ${} syntax you need to use the backticks as shown in screenshot

In the screenshot, we have used the backticks instead of normal quotes symbol.

Hope this clears your doubt.

Happy learning!

2 Likes

Thank you,
absolute life saver! :pray:

1 Like

I have another question if you can answer it, why cant you use the line breaks “\n” with these text containing variables? if i wanted to print all three in one output but on different lines how would i do that?

Hi,
You would do it this way.

console.log(`Their names \n ${fisrtName} \n ${secondName}`)

Hope this helps. :smile: