← Back to challenges

Find Number of Digits in Number

JavaScriptHardmathnumbersregex

Instructions

Create a function that will return an integer number corresponding to the amount of digits in the given integer num.

Examples

num_of_digits(1000) ➞ 4

num_of_digits(12) ➞ 2

num_of_digits(1305981031) ➞ 10

num_of_digits(0) ➞ 1

Notes

Try to solve this challenge without using strings!

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Burglary Series (04): Add its Name