Sometimes, we want to get the number of digits with JavaScript.

In this article, we’ll look at how to get the number of digits with JavaScript.

### How to get the number of digits with JavaScript?

To get the number of digits with JavaScript, we can convert the number to a string.

For instance, we write

```
const getlength = (number) => {
return number.toString().length;
};
```

to define the `getLength`

function that takes a `number`

.

In it, we call `toString`

to convert it to a string.

And then we get the `length`

property of it to get the number of digits of `number`

.

### Conclusion

To get the number of digits with JavaScript, we can convert the number to a string.