7/9: SyntaxError: missing ; before statement


#1

Can't find the mistake. Error messages:

  • Main error message "Oops, try again. Remember to add the line $('.btn').addClass('disabled'); outside your keyup event handler".

  • Error underneath the preview window "SyntaxError: missing ; before statement".

Checked the code with hint and all seams to be right:

var main = function (){
    $('.btn').click(function (){
        var post = $('.status-box').val();
        $('<li>').text(post).prependTo('.posts');
        $('.status-box').val('');
        $('.counter').text(140);
        });
    $('.status-box').keyup(function(){
        var postLength = $(this).val().length;
        var charactersLeft = 140 - postLength;
        $('.counter').text(charactersLeft);
        
        if (charactersLeft <= 0) {
            $('.btn').addClass('disabled');
            }
        else if (charactersLeft == 140) {
            $('.btn')addClass('disabled');
            }
        else {
            $('.btn').removeClass('disabled');
            }
        });
        
    $('.btn').addClass('disabled');
    };

$(document).ready(main);

Please help


#2

Hey @darthvaderkrytonite! its just a simple problem! You forgot to add the period when you added your class disabled here:

Just change that to:
$('.btn').addClass('disabled');

And you should be fine! If your not please reply saying so!


#3

Looks like my kind of mistake! :smile: Thanks a lot, it all good now :smile: