N Shortcut - SyntaxError missing ) - Please help me find it!


#1



https://www.codecademy.com/courses/web-beginner-en-4hxyb/0/9?content_from=make-an-interactive-website%3Ajquery-events#


Hi,

I'm getting this error message and I can't spot my mistake. Please help!
"Uncaught SyntaxError: missing ) after argument list"


var main = function() {
    $('.article').click(function() {
        $('.description').hide();
        $(this).addClass('.current');
        $(this).children('.description').show();
        $('.description').hide();
        $('article').removeClass('.current')
    
    });
   
   $(document).keypress(function(event) {
       if (event.which === 111)
       $('.current').children('.description').toggle();
         }
          
      else if(event.which === 110) {
  var currentArticle = $('.current');
  var nextArticle = currentArticle.next();

  currentArticle.removeClass('current');
  nextArticle.addClass('current');
        }
    });
  };
$(document).ready(main);


#2

I believe you are missing an opening bracket at you if-statement.

The function gets closed too early because of that, that's why you get the error "Uncaught SyntaxError: missing ) after argument list".


#3

I'm really sorry.. could you point out where exactly?

Thank you for replying :slight_smile:


#4

var main = function() {
    $('.article').click(function() {
        $('.description').hide();
        $(this).addClass('.current');
        $(this).children('.description').show();
        $('.description').hide();
        $('article').removeClass('.current')
    
    });
   
   $(document).keypress(function(event) {
       if (event.which === 111)                     <- You forgot the opening bracket
       $('.current').children('.description').toggle();
         }
          
      else if(event.which === 110) {
  var currentArticle = $('.current');
  var nextArticle = currentArticle.next();

  currentArticle.removeClass('current');
  nextArticle.addClass('current');
        }
    });
  };
$(document).ready(main);

#5

It worked! Thank you so much!


#6

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.