JS 'o' shortcut not working


#1

I'm still not able to figure out where I made my error. Can anyone with fresh eyes help me?

var main = function()
$(document).keypress(function(event) {
if(event.which === 111) {
$('.current').children('.description').toggle();

});
$('.article').click(function)(){
$('article').removeClass()
$('.description').hide()
$(this).addClass('current');
$(this).children('description').show();
});
};
$(document).ready(main);

Error message I get is:

Oops, try again. It looks like the o key isn't opening a description. Remember to toggle the current article's description inside the event handler. Look back at the instructions for the code.

Thanks,


#2

Hi @julienk403,

If it may help please see the following code example. In short it looks like the syntax gremlins decided to pay you a visit.
We just need to make a few changes to your code and this should hopefully get you moving forwards; there are a few brackets in the wrong place that need updating, and we can probably drop the second ($document).ready() and the top first variable main.

//var main = function() //we can leave this out at this time
$(document).keypress(function(event) {
    if(event.which === 111) {
        $('.current').children('.description').toggle();
    }; //); remove the closing bracket
    
    $('.article').click(function () { //)(){ //remove extra early closing bracket for the click method
        $('article').removeClass();
        $('.description').hide();
        $(this).addClass('current');
        $(this).children('description').show();
    });
}); //add closing bracket for the ready method

//$(document).ready(main); //Unless you have more code not pasted you probably don't need this

If this doesn't quite resolve your issue, if you could please add what Unit and step this code is for someone will try to help as soon as they can.