Step 5: counting characters - error: variables not defined


#1

I can't proceed to the next step in the tutorial, and I don't know what I am doing wrong. I am either getting an Error message that says my counter isn't updated, or that I need to make sure that all my variables are defined.

here's my coding:

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

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

    }

    $(document).ready(main) ;

    Hope someone can help - Thanks !!


  • #2

    Hi Kingkrow,

    You've got two typos that need to be fixed:

    • Line 4, prepentTo should be prependTo
    • Line 11, chractersLeft should be charactersLeft.