. Advertisement .
..3..
. Advertisement .
..4..
How to solve the problem – uncaught syntaxerror: missing ) after argument list?
I have the sample detail:
var nav = document.getElementsByClassName('nav-coll');
for (var i = 0; i < button.length; i++) {
nav[i].addEventListener('click',function(){
console.log('haha');
}
}, false);
};
While I was running it, I found the warning message:
SyntaxError: missing ) after argument list
That is my question in my midterm exam, and it is urgent.
I searched the solutions on some websites, but I didn’t get it. I may miss any line or other changes. I appreciate your assistance!
The cause:
This error happens because you we are causing a syntax error when you call a function. In particular, you are having an extra } as following:
Solution:
jsFiddle is a good tool which can help you resolve this error. You can creat a fiddle with your invalid code and click the
TidyUp
button. If there are any possible errors with missing braces, it will format and make your code clearlier.Your function has an additional closing
}
.To find these things, you should use JSHint and JSLint. These tools can be integrated with many editors or IDEs. Or you can simply paste code into one of the web sites above and request an analysis.