Skip to content

Instantly share code, notes, and snippets.

@qetr1ck-op
Last active December 21, 2015 07:57
Show Gist options
  • Save qetr1ck-op/8d46e2f512f020ec8b9e to your computer and use it in GitHub Desktop.
Save qetr1ck-op/8d46e2f512f020ec8b9e to your computer and use it in GitHub Desktop.
'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