N shortcut 2 is not working


#1

Here is my code is there a syntax error that I am not seeing?

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


#2

@northwestern,
You should understand that a pair of curly-brackets-{ }
are used to encapsulate a so-called code-block.

Thus if you have an IF ELSE statement

if ( _condition_ ) {
   // IF code-block
}
else {
   // ELSE code-block
}

OR

$(document).keypress( function (event) {
    // FUNCTION-BODY as code-block
}
); //<= closing keypress-parenthesis

Now update your document =keypress= Eventhandler