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
asked Nov 4, 2017 at 2:53
prepare123
1751 gold badge3 silver badges15 bronze badges
1 Answer 1
Wrap the string with back ticks (`) instead of single quotes (') and it will work.
answered Nov 4, 2017 at 2:58
pfcodes
1,1162 gold badges10 silver badges16 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Aravind
my comment answers this
lang-js
sum: ${sum}