count-digits
Counts the digits of an integer in any base.
Usage
countDigits(value[, base=10])
Example
var countDigits = ; ; // => 3; // => 4; // => 5; // => 2; // => 8
Installing
$ npm install --save count-digits
Notes
Zero
Zero is a special case when counting digits. Be aware that countDigits(0)
will return 0
where you might be expecting 1
.
Floats
Since only whole values are counted, countDigits(Math.PI)
will return 1
.
License
MIT.