I wanted to know what would be better to use in terms of placeholders. I’m sure they have their differences and strengths in different scenarios but I’d like to know what would be the best one to use for most cases.
function getPizza(){
return ‘ ’
}
const pizza = getPizza()
console.log(${pizza}
)
OR
function getPizza(){
return ‘ ’
}
const pizza = getPizza()
console.log(pizza)
davidgar026:
console.log(${pizza}
)
Have you actually tried this to see if it works?
Hint: You are missing something in order to use the template literal syntax.
As far as which one to use, for this simple case it really doesn’t make a difference.
But if you want to insert variables into a longer string then probably the first one will be the most convenient.
system
Closed
March 10, 2024, 10:32am
3
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.