A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript 🚀 Don't miss our Quizzes!
Let's chat: @nairihar
Post #3105
2.65K
CHALLENGE
function highlight(strings, ...values) {
return strings.reduce((result, str, i) => {
const value = values[i - 1];
const formatted =
typeof value === "number"
? `[${value * 2}]`
: `<${String(value).toUpperCase()}>`;
return result + formatted + str;
});
}
const language = "javascript";
const year = 2015;
const feature = "templates";
const output = highlight`Language: ${language}, introduced in ${year}, feature: ${feature}!`;
console.log(output);- ❤ 7
- 👍 2
- 🔥 2


