How to update the counter


What am I doing wrong?

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

  • ').text(post).prependTo('.posts');
    var postLength =$(this).val().length;
    var charactersLeft = -140 postLength;
    $('.counter=140').text() charactersLeft;

  • #2

    Hi Chris,

    I'm guessing you're on exercise six, Count characters left?

    You've got a bunch of problems in your code. From top to bottom:

    • Line 7 should be removed
    • Line 8 should have $('.status-box').keyup(function() {
    • Line 10 needs to be 140 - postLength;, not -140 postLength;
    • Line 11 should look like this: $('.counter').text(charactersLeft);
    • And on line 12, you need to add }); before the };.

    If you're still having problems, please post your updated code.
    I hope this helps :)


    Hello Zyztvan my code looks exactly like what you posted but i still get error to update '.counter.
    See my code below:

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

  • ').text(post).propendTo('.posts');
    var postLength = $(this).val().length;
    var characterLeft = 140 - postLength;


  • #4

    @lawreneagles Please create a new topic, then post the link to it here, & I'll help you over there. And if you could include the error message you're getting, as well as your code, it'd be great :)


    Thank you for your Help


    Have the same question. How to reset the counter to 140 after "Post" was clicked


    @kybinsky Please create a new topic with your code, a link to the exercise you're on, and your question - someone will help you over there :)