Home > Software engineering >  How can i create a file properly concatenating with literals?
How can i create a file properly concatenating with literals?

Time:05-17

How can i make the same result of this

word  ","   num   ","    allowed    ","   "out.csv"     "\n";

with that i am building a csv file

but i dont want to concatenate like my code above

i want to use literals

this is my attempt but does not worked

`${word, num, allowed, "out.csv"  "\n"}`;

CodePudding user response:

In a template string, each JS expression should be wrapped in its own set of braces ${} and anything outside the braces is treated as literal characters in the string, like so:

`${word},${num},${allowed},out.csv\n`;
  • Related