function lenOfNum(num) {
num = Math.abs(num)
if(num < 10 && num >= 0){
return 1
}
let len = 0
while(num > 1){
num = num / 10
len++
}
return len
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter