The N shortcut 2


#1

I keep getting the statement "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."

Below is the code I am using and I have no idea what to change to proceed from here.

var main= function() {
};
$(document).ready(main); {

$('.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');
    }
});

All/Any help is appreciated. Thank you


#2

I apologize. I just looked, and found that I too had forgotten to close my if(event.which ===111)


#3

This game i created for you may make you understand whats going on!! :smiley:


#4

@amanuel2, I'm not sure how this game is supposed to help @spencedawg85 with his code.


#5

Just to give him a concept about event.whitch(), the task he is on. I use that a lot in my JS Code of that game.


#6

@spencedawg85 That's part of the problem, but you've also closed main() before anything else. main needs to be closed just before the last line, so your code structure should look like this:

var main = function() {
 // ...
};

$(document).ready(main);

...not like this:

var main = function() {

};

// ...

$(document).ready(main);