I'm using AptanaStudio 3 and I'm getting an error with some of my javascript code:
Syntax error: unexpected token 'let'.
How do I fix this? Maybe there is some way around using let? I don't know. I've just started with Javascript and I'm a bit confused. Maybe this is only an AptanaStudio 3 issue?
const para = document.querySelector('p');
para.addEventListener('click', updateName);
function updateName() {
let name = prompt('Enter a new name');
para.textContent = 'Player1:' + name;
}
This Javascript code adds some dynamic behaviour to my html/css code.
In this context,
varis syntactically identical tolet, and is much more widely supported, particularly on Microsoft's Internet Explorer. To make your code fully ECMAScript 5 compatible, it would look like this:(Nothing has changed except replacing ES6
constandletwith ES5var.)