• Register
1 vote
63 views

Problem:

My code isn't running. In the console the error is “Uncaught SyntaxError: missing ) after argument list” but there are no missing ) I find.

Here is my code below:

var nav = document.getElementsByClassName('nav-coll');
for (var n = 0; n < button.length; n++) {
    nav[n].addEventListener('click',function(){
            console.log('haha');
        }
    }, false);
};

I’d be thankful to him if somebody pulls me up from here.

Thanks.

12 7 7
15,250 points

1 Answer

1 vote

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.

13 9 6
94,240 points

Related questions

0 votes
1 answer 15 views
15 views
I am having problem or facing the issue removing last character from string in JavaScript.
asked Sep 29 Daniel Anderson 4k points
0 votes
1 answer 9 views
9 views
I am finding the answers in several blog for removing particular character from string in java.
asked Sep 29 Daniel Anderson 4k points
0 votes
1 answer 13 views
13 views
I want to know a function built into Java that capitalizes the first character of each word in a String. It doesn&rsquo;t affect the others?
asked Sep 28 Daniel Anderson 4k points
0 votes
1 answer 6 views
6 views
I am finding difficulty with non repeated characters in a string in Java.
asked Sep 26 Daniel Anderson 4k points
0 votes
1 answer 5 views
5 views
I am finding the answers how to check string contains special characters in Java.
asked Sep 26 Daniel Anderson 4k points