Get the number's length without transforming it into a string

You can get a number's length (without transforming the number into a string) using the Math.log10() function:

javascript
let a = 12545
let a_length = parseInt(Math.log10(a)) + 1 // 5

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.