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}`;
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}`;
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'));
(`)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