Skip to content

Instantly share code, notes, and snippets.

@jurosh
Created February 3, 2019 11:08
Show Gist options
  • Save jurosh/93f1754952ae563c5e229facab1056d7 to your computer and use it in GitHub Desktop.
Save jurosh/93f1754952ae563c5e229facab1056d7 to your computer and use it in GitHub Desktop.
const interpolation = (text, ...args) => {
text;
args;
return args.reduce((acc, fn, index) => {
return acc + text[index + 1] + (typeof fn === "function" ? fn() : fn);
}, text[0]);
}
const test = interpolation`huraaay
Teraz ide ${() => 'prvy'} potom ${'druhy'} a strieborny ${'treti'}!
yea`;
test;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment