Getting the error message "SyntaxError: Parse Error" on The N Shortcut 2


#1

@zystvan having the same issue here: getting the error message "SyntaxError: Parse Error" as well as the same error message i have seen a few people have reading "the n key is isn't moving..."

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) {
        $('.description').hide();
        $('.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);

Help would be greatly appreciated!


Can't pass the n shortcut 2
#2

Hi B,

The first problem in your code is on line 6 - if you compare that line to the other lines similar to that, you should be able to see the problem, but if not, this post should help you :slight_smile::

Then, on line 14, you've forgotten to close your if statement before opening your else if statement, so you'll need to add a closing curly brace (}) right there.


I hope this helps! Please let me know if you're still having trouble with the exercise :slight_smile:


#3

A post was split to a new topic: "N Shortcut 2" - this code is breaking my head!