Skip to content

Instantly share code, notes, and snippets.

@Falci
Created May 18, 2019 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Falci/629fc3c7fef1fcac87e8e9ed6df12d2b to your computer and use it in GitHub Desktop.
Save Falci/629fc3c7fef1fcac87e8e9ed6df12d2b to your computer and use it in GitHub Desktop.
const highlight = ([...strings], ...values) => strings.reduce(
(sentence, string) => `${sentence}<strong>${values.shift()}</strong>${string}`,
strings.shift()
);
const name = 'F_NAME';
const what = 'project';
const sentence = highlight`Good luck ${name} in your new ${what}`;
console.log(sentence); // Good luck <strong>F_NAME</strong> in your new <strong>project</strong>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment