3

enter image description here

The above is a screenshot a tutorial in which the tutor used ${ var } to print a variable in js.

But when i ran the same code, i got like this: enter image description here

What is the actual problem?

3
  • 2
    you used ' to format the string, you have to use `(backtick) Commented Dec 1, 2018 at 5:35
  • 2
    You need to use backtick(`) instead of '. Commented Dec 1, 2018 at 5:35
  • 3
    What you are looking for is template literals. Take a look at this: stackoverflow.com/a/50922888/8349557 Commented Dec 1, 2018 at 5:37

3 Answers 3

6

enter image description here

you must use the backtick [ ` ] ; instead of the using [ ' ],So you can solve it.

Sign up to request clarification or add additional context in comments.

Comments

4

You're using the wrong quote type. To do what you want you'll need to use backtick. It's the one to the left of the 1 key on most keyboards.

Comments

3

console.log(Server at port ${port}) // Don't put "" or ''. Use ``

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.