How to get the length of a number in Node.js

2 Answers

0 votes
const integer = 900871;

console.log(integer.toString().length); 

 
   
   
   
   
/*
run:
   
6
   
*/

 



answered Jun 22, 2022 by avibootz
0 votes
const float = 94871.9;

console.log(float.toString().length - 1); 

 
   
   
   
   
/*
run:
   
6
   
*/

 



answered Jun 22, 2022 by avibootz

Related questions

1 answer 130 views
1 answer 125 views
1 answer 142 views
1 answer 112 views
1 answer 88 views
...