Skip to content

Instantly share code, notes, and snippets.

@Kannndev
Created October 16, 2020 16:51
Show Gist options
  • Save Kannndev/f4f81c23b3809dfdb624c2fba32633f9 to your computer and use it in GitHub Desktop.
Save Kannndev/f4f81c23b3809dfdb624c2fba32633f9 to your computer and use it in GitHub Desktop.
Funtion that transforms dynamic value to bold elements
const makeBold = (strings, ...values) => {
let str = '';
strings.forEach((string, i) => {
str += `${string} ${values[i] ? `<strong>${values[i]}<strong>` : ''}`;
});
return str;
}
const name = 'Kannan';
const role = 'Javascript developer';
makeBold`My name is ${name} and I am a ${role}`;
// My name is <strong>Kannan<strong> and I am a <strong>Javascript developer<strong>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment