INBOX
Tagged template literals
tagFunction`template literal text`;function highlight(strings, ...values) {
return strings.reduce((result, str, i) => {
return `${result}${str}<b>${values[i] || ''}</b>`;
}, '');
}
const name = 'John';
const age = 30;
const result = highlight`Hello, my name is ${name}, and I am ${age} years old.`;
console.log(result);
// Output: "Hello, my name is <b>John</b>, and I am <b>30</b> years old."Last updated