-1

I have this string variable inside javascript function. When I run this page in IE with this script I am getting invalid character error at for below line.

let displayString = `${seconds < 10 ? '0' : ''}${seconds}`;
user1030181
  • 1,995
  • 5
  • 26
  • 56

2 Answers2

0

The backticks notation (template literals) is not supported in IE.

A possible workaround would be:

let displayString = seconds < 10 ? '0' : '';
displayString += seconds;

It seems what you want is to pad left with zeros, so that the number is always at least two digits. To achieve that, you could use padStart():

//pad left with the character '0' so that length is at least 2 digits
console.log("7".padStart(2, '0'));
console.log("17".padStart(2, '0'));
Anis R.
  • 6,656
  • 2
  • 15
  • 37
  • How about this one ``pointer.style.transform = `rotate(${360 * value / (timePercent)}deg)`;`` – user1030181 May 14 '19 at 14:25
  • I did this but I am getting rotate is undefined error `var test = (360 * value / (timePercent)); pointer.style.transform = rotate(testdeg);` – user1030181 May 14 '19 at 14:47
  • The backtick notation is for strings. I assume what you wanted to do is `pointer.style.transform = "rotate(" + testdeg + ")";` ? – Anis R. May 14 '19 at 14:58
  • Yes I wanted to do like you have suggested but getting the testdeg is undefined error – user1030181 May 14 '19 at 15:21
0

(`)Template string literals is new features of ES6

So, This is not supported in IE browser.

Please refer the below link for more information ES6-Template-Strings Reference