

var addDigits = function(num) {
   if(num === 0){
        return 0;
   }
   if(num%9 === 0){
       return 9;
   }
   else{
      return num%9;
   }
};


var addDigits = function(num) {
    if(num<10){
        return num;
    }
    var strArr = num.toString().split("");
    var sum = strArr.reduce(function(a,b) {return Number(a) + Number(b)});
    if(sum.toString().split("").length === 1){
        console.log(sum);
        return sum;
    }else{
        addDigits(sum);
    }
};
addDigits(56);

@@ -1,28 +1,329 @@
+// Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.%0A%0A// For example:%0A%0A// Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it.%0A%0A// Follow up:%0A// Could you do it without any loop/recursion in O(1) runtime?
 %0A%0Avar addDigits = function(n

add desription