Lesson 5 - Error message: Make sure you have defined all the variables


#1



https://www.codecademy.com/courses/web-beginner-en-hk5qh/0/5?content_from=make-an-interactive-website%3Ajquery-dom-manipulation#


I get the error message: "...Make sure you have defined all the variables"


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 - postlLength;
        $('.counter').text(charactersLeft);
            
});
}

$(document).ready(main);


#2

@ajgoddard

Have a close look at

postlLength


#3

Thank you Leonhard... that worked. You're a gem! I looked that over a couple of dozen times at least.

Please tell me spotting these things/proofing one's own code becomes easier over time.


#4

@ajgoddard

Please tell me spotting these things/proofing one's own code becomes easier over time

It does, but there will always be problems in your code that take you hours to find. The better you get, the more complex stuff you'll be building, so although it gets slightly easier, it can still be very difficult at times :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.