Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tagged template sample
const generateIntro = (strings, ...values) => {
console.log(strings); // [ 'My name is ', ' and I am a ', '' ]
console.log(values); // [ 'Kannan', 'Javascript developer' ]
let str = '';
strings.forEach((string, i) => {
str += string + (values[i] || '');
});
return str;
}
const name = 'Kannan';
const role = 'Javascript developer';
generateIntro`My name is ${name} and I am a ${role}`;
// My name is Kannan and I am a Javascript developer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment