Get the number of figures in JavaScript

Transform the number into a string and get the length of it using number.toString().length.

Example:

javascript
let x = 10
console.log(x.toString().length)
// 2

let y = 100
console.log(y.toString().length)
//3

let z = 1000
console.log(z.toString().length)
// 4

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