Counter not updating, getting error


#1

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

That's the error msg i get. Here is my code, I can't see what's wrong with it:

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

  • ').text(post).propendTo('.posts');
    $('.status-box').val('');
    });
    $('.status-update').keyup(function(){
    
    var postLength = $(this).val().length;
    var characterLeft = 140 - postLength;
    $('.counter').text(characterLeft);
    
    });

    };

    $(document).ready(main);


  • #2

    Hi Lawreneagles,

    You've got a couple issues with your code:

    • On line 4, you misspelled prependTo as propendTo
    • On line 6 you should reset .counter's text() to 140.
    • On line 9 you need to select .status-box, not .status-update

    And I suggest you name your charactersLeft variable properly, with the plural characters, but since that's not currently causing an error, it's not important.

    I hope this helps!