Stoopid question time!
var num = 1024; len = num.toString().length; console.log(len);
Well, I don't think providing length properties to number will be helpful. The point is the length of strings does not change by changing its representation.
for example you can have a string similar to this:
var b = "sometext";
and its length property will not change unless you actually change the string itself.
But this is not the case with numbers.
The same number can have these two representations:
var a = 23e-1; and var b = 2.3;
So with these two representation its clear that same number can have multiple representation and so, if you have length property with numbers it will have to change with the representation of the numb.er
you must set variable toString() first, like this:
var num = 1024, str = num.toString(), len = str.length; console.log(len);