Uncaught SyntaxError: Unexpected token else


#1

The following code is not working.

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

With the error

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.

and

Uncaught SyntaxError: Unexpected token else

Any help would be appreciated. :smile:


#2

Hi Anika,

In JavaScript (and most languages), a semi-colon (;) represents an end of the current statement. So you need to not have one at the end of your if statement, because then the computer isn't expecting an else if statement :slightly_smiling:
Also, you should remove the > on the last line.