Step 5: count characters left


#1

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

here 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

Hi Mohamed,

You should probably change your username right now, since your email address is currently visible

Your code worked for me, both in passing the exercise and in functioning properly.
Have you tried refreshing the page or switching browsers? That might 'fix' the issue :)


#3

I tried Safari instead of Chrome and nothing changed.


#4

Still works for me, on Firefox 44.0a2 on Linux.
Is the code you posted above your complete code?
And also, is line 4 exactly like this?

$('<li>').text(post).prependTo('.posts');

#5

yea it's the complete code and yes line 4 is exactly like that.


#7

4 posts were split to a new topic: Exercise 5, "Remember to update the '.counter' to show how many characters are left" error


#8

The only thing that you need to change with your code is you need to backspace once on line 4, that should put everything on one line. it worked for me