5. Count characters left


#1

I keep getting this error:
Oops, try again. Remember to update the '.counter' to show how many characters are left.

Can you help me out? This is my code:

var main = function() {
$('.btn').click(function() {
var post = $('.status-box').val();
$('

  • ').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);


  • #2

    @juulwil

    Look here

    It's postLength not postlenght


    #3

    Thanks a lot, but I still get the same error.


    #4

    @juulwil
    I think the code works fine but you will need to create a new li attribute to a append the new message to in this line:

    $('').text(post).prependTo('.posts');