Uncaught SyntaxError: Unexpected token else


The following code is not working.

var main = function(){
        if (event.which === 111) {
        else if (event.which === 110) {
            var currentArticle = $('.current');
            var nextArticle = currentArticle.next();
    };> $(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.


Uncaught SyntaxError: Unexpected token else

Any help would be appreciated. :smile:


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.