I currently have a script in Google Tag Manager, which when I am going ot publish, is giving me x 2 JavaScript compiler errors
JavaScript compiler error
Error at line 3, character 7: This language feature is only supported for ECMASCRIPT6 mode or better: const declaration.
Error at line 4, character 18: This language feature is only supported for ECMASCRIPT6 mode or better: arrow function.
Here is my code:
<script>
(function() {
const h4 = document.querySelectorAll('.h4');
h4.forEach(el => {
el.innerHTML = el.innerHTML.replace(/sweater/gi, 'jumper');
});
})();
</script>
This is working correctly in DevTools. Is there a one size fits all resolution for these errors, or is it bespoke depending on your code?
Thanks,