Last active
December 21, 2015 07:57
-
-
Save qetr1ck-op/8d46e2f512f020ec8b9e 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
'use strict'; | |
function str(strings, ...values) { | |
let str = ""; | |
values.forEach((val, i) => { | |
str += strings[i]; | |
str += values[i]; | |
}) | |
// the last chunk of string | |
str += strings[strings.length-1]; | |
return str; | |
} | |
let apples = 3; | |
let oranges = 5; | |
// Sum of 3 + 5 = 8! | |
alert( str`Sum of ${apples} + ${oranges} = ${apples + oranges}!`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment