Push Menu interactivity


#1

Hey lo,
I'm on the beginning of adding Interactivity, adding a Push menu:

https://www.codecademy.com/en/courses/web-beginner-en-zmn0b/0/5?content_from=make-an-interactive-website%3Ayour-first-program#

My screen reads: SyntaxError: missing } after function body

However the bottom of the screen says "Way to go! Start next lesson" so seems to think I've done it, even though the code doesn't actually work. I presume this is an issue with the website, which is disheartening given we've come here to learn coding.

var main = function() {

$('.icon-menu').click(function () {
    $('.menu').animate({
        left: '0px'
    }, 200);
    
    $('body').animate({
        left: '285px'
    }, 200);

});

Why is it saying there's a missing } I can't seem to spot it?
Thanks


#2

you forgot to close the function

var main = function() {

$('.icon-menu').click(function () {
$('.menu').animate({left: '0px'}, 200);
$('body').animate({left: '285px'}, 200);
});

} // close the function


#3

I have tried adding the } as you suggest at the end of the code, but the error message remains the same: 'Syntax error: missing } after function body'

I don't understand where it has to go, re-read my notes but it doesn't make sense....?


#4

yes.you didn't close. :slight_smile:

you closed it .click(function () { ........................}

you have to close it too var main = function() {................................}


#5

Thank you! That's so strange, I swear I tried that 100 times but suddently I did it & the error message went away. Many thanks


#6

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