5.Count Characters Left - Help


#1

Hello all.
I have been learning to code for a few months now, so am very new. I have been experiencing problems creating the correct code to pass the section '5.Count Characters Left'. I would be grateful if somebody more experienced could check my code for errors. I have re-written it a few times based on my notes from the lessons, and have read a fair few of these posts and am still unable to create the correct code to pass. Thank you all for your help.

var main = function() {

$('.btn').click(function(){
    var post = $('.status-box').val();
    $('<li>').text(post).prependTo('.posts');
    $('.status-box').val(..);
});

$('.status-box').keyup(function(){
    var postLength = $(this).val().length;
    var charactersLeft = 140 - postLength;
    $('.counter').text(charactersLeft);
});

};

$(document).ready(main);

The error is:
'Oops, try again. Remember to update the '.counter' to show how many characters are left.'


#2

Hi here

 $('.status-box').val(..);

inside val() try to remove the ...


#3

Hello Wizmarco,

I removed the .. however I still get the same error appear. Any other thoughts? I also tried deleting my whole jQuery code and retyping it, but still stuck!

Louise


#4

Ok, I think I may have found the error - for anybody else struggling! I changed the closing brace from:

};

to

})

and it was accepted. I also left out the .. from val as so

.val();

and bracketed the calculation 140-postLength

= ( 140 - postLength );

Thank you for the help, and I hope this can help anyone else stuck!


#6