--DAY 26--
Hi, I am going to make #100DaysOfCode Challenge. Everyday I will try solve 1 problem from leetcode or hackerrank. Hope you can go with me until end.
Now let's solve problem today:
Problem: Add Digits
Detail: here
My solution (javascript):
var addDigits = function(num) {
if(num<=9) return num;
let n=0;
while(num>0){
n+=num%10;
num=Math.floor(num/10);
}
return addDigits(n);
};
-->If you have better solution or any question, please comment below. I will appreciate.
Top comments (1)
return m