I have this JS function
function trans(key, replace = {})
{
let language = 'de';
if(window.currentLanguage !== undefined) {
language = window.currentLanguage;
}
let translation = key.split('.').reduce((t, i) => t[i] || null, window.translations[language]);
for (var placeholder in replace) {
translation = translation.replace(`:${placeholder}`, replace[placeholder]);
}
return translation;
}
It works fine in Chrome, Firefox, Opera etc. But in IE (Mode 11) it throws this error:
")" expected
Actually, there is no error, otherwise it would not work in Chrome etc. And I also checked all brackets. Each opening bracket is being closed. How can I re-write this function, that it works in IE (Mode 11) also?