1

I am trying to convert a double quoted string containing template literal into tilde string such that I can pass values inside the string.

Sample:

const email = "hello there ${user_name}"

const emailParser = (email)=>{

let user_name = "alex"
console.log(`${email}`)
console.log(`hello there ${user_name}`)

}

emailParser(email)

Result

hello there ${user_name}
hello there alex

I would like to know, if there is some method to achieve the result of first console log to be like that of second console log.

Cruze LX
  • 21
  • 4

0 Answers0