create a function that takes a number as an argument and returns the amount of digits with +1 javascript code example
Example 1: digit count in javascript
function digitCount(num) {
if(num === 0 ) return 1
return Math.floor(Math.log10(Math.abs(num))) + 1
}
Example 2: get the whole value of a number javascript
var value = 2.9802453587962963;
var wholeNum = Math.floor(value);
console.log(wholeNum); // output ==> 2