Skip to content

Commit 597643e

Browse files
committed
countofdigit
1 parent b527966 commit 597643e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Programs/DSA/count.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
/*
3+
3. WAP Count Of a Digit
4+
input- 521
5+
output - 3
6+
*/
7+
8+
9+
function countofdigit(num) {
10+
11+
let count = 0
12+
13+
while (num > 0) {
14+
15+
num = Math.floor(num / 10)
16+
count++
17+
}
18+
19+
return count
20+
}
21+
console.log(countofdigit(251))//3
22+
console.log(countofdigit(4528))//4

0 commit comments

Comments
 (0)