when I remove the semicolon on the 3rd line my javascript code breaks and I get this error “ReferenceError: Cannot access ‘updatedTasks’ before initialization
at moveTaskUp”.I always thought that JavaScript’s automatic semicolon insertion always worked
function moveTaskUp(index){
if(index>0){
const updatedTasks=[...tasks];
[updatedTasks[index],updatedTasks[index - 1]]=[updatedTasks[index-1],updatedTasks[index]]
setTasks(updatedTasks)
}
}
I guess I’m put a semicolon on every line of js from now on
New contributor
user17728044 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.