0

New to Visual Studio Code and Node here.

I wrote this line of code as part of a tutorial and run it through node.

const textOut = 'This is what we know about the avocado: ${textIn}.\nCreated on ${Date.now()}';

and the ${textIn} and ${Date.now()} do not generate the JavaScript as it should, but when I copy and paste the line directly from the tutorial

const textOut = `This is what we know about the avocado: ${textIn}.\nCreated on ${Date.now()}`;

it works perfectly. I did notice that on the line directly from the tutorial, the JavaScript portion is a different color but not on the one I wrote. Is there something I'm supposed to be doing to format JavaScript in Visual Studio Code?

enter image description here

I tried finding solutions online to no help.

InSync
  • 4,851
  • 4
  • 8
  • 30
beastMode
  • 11
  • 1
  • It's a rather simple game of spot the difference. Once you have backticks `\`` and the other time you have single quotes `'`. That does matter in JavaScript. See [template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals). – Mushroomator Aug 04 '23 at 18:50
  • thank you bud. rookie mistake. my bad. – beastMode Aug 04 '23 at 18:59

0 Answers0