r/learnjavascript • u/PlusAd945 • Jul 03 '26
Question about backtick variables
Can anyone please help me with this?
I am learning JavaScript and in chapter 2 of the book I am using it talks about backtick variable with format ${variablename}. It has an example to be posted into the Console using console.log().
let language = "JavaScript";
let message = "Let's learn ${language}";
console.log(message);
The output in the console is supposed to be: Let's learn JavaScript. But what I keep getting is: let's learn ${language}
The same thing happens with other examples in the chapter, in Chrome and Edge.
Can anyone tell me why?
View all comments
Show parent comment
1
u/Psionatix Jul 04 '26
3 backticks on reddit is no longer code formatting, it might on the old UI, but not any more for the app. Just indent each line of code with an initial four spaces instead, making sure to have a blank new line before / after.