The N shortcut - problems with my code


#1


I'm stuck on the N shortcut exercise. I'm not sure what my error is. My code is below.

This is the error message I'm getting:


Oops, try again. It looks like the n key isn't moving to the next article. Remember to remove the 'current' class from currentArticle and place it on nextArticle.


var main = function() {
  $('.article').click(function() {
    $('.article').removeClass('current');
    $('.description').hide();

    $(this).addClass('current');
    $(this).children('.description').show();
    
  });
  
  $(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");
  }
  });
};


#2

@compreal,
For Javascript a semi-colon-; is an End-of-Statement indicator.

If you use this semi-colon-; in a IF ELSE-IF statement structure,
the ELSE-IF statement will not be seen as being part of the IF ELSE-IF statement.

  • 1 $(document).keypress(function(event) {;

  • 2 if (event.which === 111) {
    $('.current').children('.description').toggle();
    };


#3

I took out the semi-colons in my if, else if statement but I am getting the same error. Here is my code now:

var main = function() {
$('.article').click(function() {
$('.article').removeClass('current');
$('.description').hide();

$(this).addClass('current');
$(this).children('.description').show();

});

$(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);


#4

@compreal
And what is with this semi-colon-;

$(document).keypress(function(event) {;