Solution:
We should always keep a sharp eye on our details in the code. Even a single semicolon (;) does matter here a lot.
As I can see all your logic, declaration and iteration are fine except parenthesis. You put an extra parenthesis in your code after the line
console.log('haha');
I’ve removed the extra parenthesis from your code. Now it should run error-free. Give it a try now.
var nav = document.getElementsByClassName('nav-coll');
for (var n = 0; n < button.length; n++) {
nav[n].addEventListener('click',function(){
console.log('haha');
}, false);
};
Thanks.