// Template Literals in javascript
// Longhand:
let firstName = "Chetan", lastName = "Nada";
const welcome = 'Hello my name is ' + firstName + ' ' + lastName;
console.log(welcome); //Hello my name is Chetan Nada
// Shorthand:
const welcome_ = `Hello my name is ${firstName} ${lastName}`;
console.log(welcome_); //Hello my name is Chetan Nada
//Must use backticks, `, in order to work.
let a = 5;
let b = 10;
console.log(`Fifteen is ${a + b} and
not ${2 * a + b}.`);
//Output:
//Fifteen is 15 and not 20.
let fruits = {
banana: 1,
orange: 5
};
let sentence = `We have ${banana} Banana/s and ${orange} orange/s!`;
console.log(sentence); // We have 1 Banana/s and 5 orange/s!