wetlip
wetlip

Reputation: 133

string in a string with template literals

i want to make a string in a string with a template literal in javascript ecma6. Is it possible to add the double or single quotes to the tamplate litaral output in the string. i came accross this problem using the output of a directory in a string from path as a string.

let input = "C:\users\document"

i want to child.stdin.write('athom project --run "C:\users\document" \n')

i came to this child.stdin.write('athom project --run "' +${input}+ '"C:\users\document \n')

isnt there a neater way to do it in ecma6 ?

Upvotes: 0

Views: 67

Answers (1)

Rick Hitchcock
Rick Hitchcock

Reputation: 35680

A template literal is delimited by backticks (`). You're currently trying to delimit it with single quotes.

Do this:

let input = "C:\users\document";
child.stdin.write(`athom project --run "${input}"\n`);

Upvotes: 4

Related Questions