Created
February 3, 2019 11:08
-
-
Save jurosh/93f1754952ae563c5e229facab1056d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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