Created
April 16, 2017 20:13
-
-
Save mwq27/01314d980ed3fffd11a2426834abd286 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 translator = { | |
"Hello": "Hola" | |
}; | |
function spanish(strings, ...values) { | |
return strings.reduce(function(str, val, idx) { | |
return str + (idx > 0 ? translator[values[idx - 1]] : '') + val; | |
}, ''); | |
} | |
const phrase = "Hello"; | |
console.log( | |
spanish`The word for Hello is ${phrase}` | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment