Skip to content

Instantly share code, notes, and snippets.

@bharathvaj-ganesan
Last active February 8, 2018 08:18
Show Gist options
  • Select an option

  • Save bharathvaj-ganesan/a04a3ac7c12f6bafe281a06c80078959 to your computer and use it in GitHub Desktop.

Select an option

Save bharathvaj-ganesan/a04a3ac7c12f6bafe281a06c80078959 to your computer and use it in GitHub Desktop.
function highlight(strings, ...values) {
// here i is the iterator for the strings array
return strings.reduce((result, string, i) => {
return `${result}${string} <cite>${values[i] || ''}</cite>`;
}, '');
}
const author = 'Thomas A. Edison';
const statement = `I have not failed. I've just found 10,000 ways that won't work.`;
const quote = highlight`${statement} by ${author}`;
console.log(quote)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment