Created
October 8, 2016 17:08
-
-
Save agoalofalife/9ced42bbefe1b4fcaf36d958a628a1dc 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
let name = 'Maria'; | |
let name2 = 'Vasilij'; | |
let age = 18; | |
let result = tag`My name ${name} sd sdc sdc and ${name2} and ${age}`; | |
function tag(srting,...values) { | |
return srting.reduce((prev,current,id) => { | |
if (id > 0) { | |
if (typeof values[id - 1] == 'string') { | |
prev += `@${values[id - 1]}`; | |
} | |
else { | |
prev += values[id-1]; | |
} | |
} | |
return prev + current; | |
}); | |
} | |
console.log( result ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment