function getMessage() {
const year = new Data().getFullYear();
return `The year is ${year}.`;
}
getMessage();
The template strings use back-ticks symbol rather than the single or double quotes we're used to with regular strings. We can use template strings whenever we're using strings where we have to mix tons of different variables
Refactor the function to use template strings
function doubleMessage(number) {
return "Your number doubled is " + (2 * number);
}
function doubleMessage(number) {
return `Your number doubled is ${2 * number}`;
}
Refactor the function to use template strings.
function fullName(firstName, lastName) {
return firstName + lastName;
}
function fullName(firstName, lastName) {
return `${firstName} ${lastName}`;
}