0

hi I'm get started typescript. I studied that typescript is javascript's super set So We can use javascript in Typescript File.

I'm wrote this code.

const words = '1,2,3,4'.split(',');
let sum = 0;
words.forEach(w => sum += parseInt(w));
console.log('sum:   ${sum}');

that's output should be in console

sum: 10

but that's result was

sum: ${sum}

I studied that in ES6 ' ${} 'means expression like Kotlin
can I use ES6 expression in TS ? I'm using WEBSTORM

3
  • need to use backticks `sum: ${sum}` Commented Nov 4, 2017 at 2:56
  • you should enclose inside backTicks `` sum: ${sum} Commented Nov 4, 2017 at 2:57
  • thank you very much!! it's work!! Commented Nov 4, 2017 at 3:31

1 Answer 1

1

Wrap the string with back ticks (`) instead of single quotes (') and it will work.

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

1 Comment

my comment answers this

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.