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.

3

2 Answers 2

0

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

const a = 'hi';
console.log('${a}');
console.log(`${a}`);

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

Comments

0

Use ` (and the right variable name):

console.log(`The current user is ${currentUser}`)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.