6. Reset the counter - using "140" or 140 in the text() method?


#1



My solution is as below, and there is one difference between hint solution and mine.
I am wondering as the topic title. 
Is there any difference between using "140" or 140 in the text() method?

var main = function() {
    $('.btn').click(function() {
        var post = $('.status-box').val(); 
        $('<li>').text(post).prependTo('.posts');
        $('.status-box').val('');
        $('.counter').text(140);
    });
    
    $('.status-box').keyup(function() {
        var postLength = $(this).val().length;
        var charactersLeft = 140 - postLength;
        $('.counter').text(charactersLeft);
    });
};

$(document).ready(main);


#2

jQuery's .text() function will accept a String, Number or Boolean.

If a Number or Boolean is supplied, it will automatically be converted to a string representation.


#3

Thank you for answering me! May I ask you more question?
Although the final result seems to be same, which one would be a good convention i should adopt?


#4

I don't think there is any convention for that particular case - it really depends on the code you have and which functions you plan on using.

Many Javascript functions (such as maths operators) are capable of automatically converting strings to integers, but there are also parse functions available which will convert between data types. That's why it's also recommended to store values in variables (I'm thinking of your 140 in particular).