Stuck On The O Shortcut


#1

Can anyone tell me what I am doing wrong?

Code:

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


When I press run it says, "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."


#2

@jackesche,

You are using a semi-colon-; in your IF ELSE-IF statement structure,
which then interrupts the flow-control.

For Javascript the semi-colon-; is an End-of-Statement indicator....!!!

Your IF ELSE-IF statement would end....

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

Remove the semi-colon-;

http://stackoverflow.com/questions/17036135/why-is-it-that-semicolons-are-not-used-after-if-else-statements
http://stackoverflow.com/questions/25101936/why-does-adding-a-semicolon-sometimes-break-an-if-statement