15 lines
311 B
JavaScript
15 lines
311 B
JavaScript
function digits_count(n) {
|
|
var count = 0;
|
|
if (n > 1) ++count;
|
|
|
|
while (n / 10 >= 1) {
|
|
n /= 10;
|
|
++count;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
|
|
console.log(digits_count(12112));
|
|
|
|
console.log(digits_count(457));
|