I'm trying to create an object with string templates in it. How do I do that? If I use double quotes for the message -- see below -- I'm not getting a template. If I use back-ticks, I'm getting an error.
const templates = {
"hello": {message: `Hello ${name}!`},
"price": {message: `How much is this ${product}?`}
}
The idea is to return a custom message that looks something like this. The code below is not complete but you'll get the idea.
const getMessage = (type, name, product) => {
const message = templates[type].message;
return message;
}