N shortcut 2 issues


#1



Hello, I'm having issues with this code I continue to get the error that the n key is not moving. I can't figure out the issue and have followed the picture but still seem to be having issues.

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


My error message: 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


Replace this line with your code. 

My code( Problem area is emphasised ) :
 var main = function() {

$('.article').click(function(){
$(this).children('.description').show();
});
};
$(document).keypress(function(event){
if(event.which === 111)
_else if(event.which === 110) {_
_ var currentArtiicle = $('.current');_
_ var nextArticle = currentArticle.next();_
_ _
_ currentArticle.removeClass('current');_
_ nextArticle.addClass('current');_
_}_
('.article').children('.description').toggle();
}
});:


#2

Hi @kenadat,

You've got a few typos in your code, but the main problem is that you haven't closed your if statement before creating your else if statement. Try fixing that first, then post your updated code :slight_smile:


#3

Hello @zystvan,

var main = function() {

$('.article').click(function(){
$(this).children('.description').show();
});
};
$(document).keypress(function(event){
if(event.which === 111){
}
else if(event.which === 110) {
var currentArtiicle = $('.current');
var nextArticle = currentArticle.next();

currentArticle.removeClass('current');
nextArticle.addClass('current');
}
('.article').children('.description').toggle();
}
});
Like this? is there something that should be in the curly brackets that I might of missed?


#4

@kenadat Much better, now you need to figure out what to put in your if statement :slight_smile:

You do have a stray closing curly brace (}) on line 6 that should be moved to the next to last line, as well as a missing dollar sign ($) at the beginning of line 17.


#6

I'm sorry to bother you but there still seems to be an issue I still have the same error message.

var main = function() {

$('.article').click(function(){
$(this).children('.description').show();
});
;
$(document).keypress(function(event){
if(event.which === 111){
$('.current').children('.description').toggle();
}
else if(event.which === 110) {
var currentArtiicle = $('.current');
var nextArticle = currentArticle.next();

currentArticle.removeClass('current');
nextArticle.addClass('current');
}
$('.article').children('.description').toggle();
}}
});


#7

@kenadat No worries, that's fine :slight_smile:

OK, three changes and you should be able to pass the lesson:

  1. Fix your spelling of “article” on line 12
  2. Move the closing parenthesis ()) at the end of line 20 to the end of line 19
  3. Call the main function with $(document).ready(main); at the bottom of your code

#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.