Can't pass the n shortcut 2


#1

Hi. I can't seem to pass this. can anyone help?

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

#2

Hi Nurulhusna97,

It looks to me like you're not calling the main() function. Try adding

$(document).ready(main);

at the end of app.js, and I think your code will work. If not, please reply & I'll take another look at it :)


#3

Mine looks exactly the same too but I can't seem to pass either. I don't understand. It looks exactly the same as the hint. Did you manage to pas in the end?


#4

I realised that right after I posted the code and it worked. Thanks though ^^


#5

A post was split to a new topic: Getting the error message "SyntaxError: Parse Error" on The N Shortcut 2


#6