模板字符串不起作用

nsu*_*239 -1 javascript template-strings visual-studio-code

模板字符串应可在任何终端上使用,例如Visual Studio代码终端或Windows终端。但事实并非如此。我做了这段代码Visual Studio代码。这是我的代码

var name = 'Andrew';
console.log('Hello ${name}');
Run Code Online (Sandbox Code Playgroud)

输出是

Hello ${name}
Run Code Online (Sandbox Code Playgroud)

Please specify changes in my code needed and explain why it doesn't work currently.

Dan*_*ite 6

Single and double quotes wont invoke the behavior - use back ticks.

var name = 'Andrew';
console.log(`Hello ${name}`);
//          ^             ^
Run Code Online (Sandbox Code Playgroud)

More information on Template literals,