when i write this code in vs:
const firstName = "Mohamed";
const lastName = "Eldamaty";
const sentence = 'Hello ${firstName}' ;
console.log(sentence);
the result is Hello ${firstName}
I want to concatenate it with first name
any body help me to fix this problem
CodePudding user response:
You have to use backticks instead of normal quotationmarks.
const firstName = "Mohamed";
const lastName = "Eldamaty";
const sentence = `Hello ${firstName}` ;
console.log(sentence);
CodePudding user response:
You are not using template strings, so absolute value is being logged. Do this:
const sentence = `Hello ${firstName}` ;
Use backticks (`) to use template strings.
