Sometimes, we want to fix unexpected string concatenation with JavaScript.
In this article, we’ll look at how to fix unexpected string concatenation with JavaScript.
How to fix unexpected string concatenation with JavaScript?
To fix unexpected string concatenation with JavaScript, we can use template literals.
For instance, we write
const ANR = "Animal Friend,ANR,ANP,$30";
const specialityPlates = [
{
cName: "Environmental",
oSubMenu: [
{
cName: `${ANR}`,
cReturn: `${ANR}|27.00`,
},
],
},
];
to put the ANR
into the template literal to return a string with ANR
‘s content in it.
Conclusion
To fix unexpected string concatenation with JavaScript, we can use template literals.