The n shortcut 2 (Variables)


#1



Hi It keeps on saying that i have to define all the variables but I think I have already did that. please help.

https://www.codecademy.com/courses/web-beginner-en-4hxyb/0/9?content_from=make-an-interactive-website%3Ajquery-events#


Oops, try again. Make sure you have defined all variables!


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 CurrentAtricle = $('.current');
       var nextArticle = currentArticle.next();
       
       currentArticle.removeClass('current');
       nextArticle.addClass('current');
    }
});
$(document).ready(main);


#2

You have displaced curly braces. Line 8 curly brace and semi-colon should go below where you end the main function. See below.

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

Hope this helps! :smile:


#3

You also spelled CurrentAtricle instead of currentArticle