Created
October 16, 2020 16:51
-
-
Save Kannndev/f4f81c23b3809dfdb624c2fba32633f9 to your computer and use it in GitHub Desktop.
Funtion that transforms dynamic value to bold elements
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
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