, . , , string , , . , :
function length(s)
{
return s.length;
}
With this function, you can only work with strings, because if the user inserts a number as an argument, the length property is undefined, because the Number object does not have this property, so you must specify a variable:
function length(s)
{
s=s+"";
return s.length;
}
and this time it works.
mck89 source
share