Answers for "function that count number of digit javascript"

2

count the total number of digits of a number in javascript

const count = n => String((Math.abs(n))).length;

count(123); // ➞ 3
count(-45678); // ➞ 5
count(8912); // ➞ 4
Posted by: Guest on April-22-2021
0

digit count in javascript

function digitCount(num) {
  if(num === 0 ) return 1
  return Math.floor(Math.log10(Math.abs(num))) + 1
}
Posted by: Guest on October-03-2020

Code answers related to "function that count number of digit javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language