//Template strings allow you to inject values into a string while
//preserving the format. Your code becomes more reader friendly.
//Use it instead of 'string arithmetic'.
let userName = 'John Doe';
let finalResult = 234;
//template string
console.log(`Hello ${userName} your final result is ${finalResult}`);
//'string arithmetic'
console.log("Hello " + userName + " your final result is " + finalResult);
var name = 'World';
var cname = 'javaTpoint';
console.log(`Hello, ${name}!
Welcome to ${cname}`);
const classes = `header ${ isLargeScreen() ? '' :
`icon-${item.isCollapsed ? 'expander' : 'collapser'}` }`;
/*
The template string is indicated with a dollar sign and curly brackets
(${expression}) inside the backtick symbol.
*/
//Template String
const name = 'Muhammad Shahnewaz';
const result = `${name} is a good boy`;
console.log(result); //Muhammad Shahnewaz is a good boy
function hello(firstName, lastName) {
return `Good morning ${firstName} ${lastName}!
How are you?`
}
console.log(hello('Ranjeet', 'Andani'))
const name = 'JavaScript';
console.log(`I love ${name}`); // I Love JavaScript