0

I am trying to create some string literals for my code in typescript on the firebase cloud functions platform. I am using VS code as my code editor.

I have looked across the internet and have gotten the same answer (shown below), which doesn't seem to be working. This shouldn't be too complicated

const currentUser = "Johnny appleseed"
console.log('The current user is ${currentUserID}')

I want the log to say 'The current user is Johnny appleseed' but the code doesn't compile because the variable currentUser is never read from. I would prefer a solution that doesn't include string concatenation as it would be a pain to code.

Austin R.
  • 25
  • 5

2 Answers2

0

You need to use back ticks (`), not single quotation marks ('), to use template literals:

const a = 'hi';
console.log('${a}');
console.log(`${a}`);
fjc
  • 5,590
  • 17
  • 36
0

Use ` (and the right variable name):

console.log(`The current user is ${currentUser}`)
Jb31
  • 1,381
  • 1
  • 10
  • 19