Share my simple Js solution


  • 0
    F
    var addDigits = function(num) {
        var sum=0,temp;
        while(num){
            temp=num%10;
            sum+=sum+temp>=10?temp-9:temp;    
            num=parseInt(num/10);
        }
        return sum;
    };
    

    this is my simple solution


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.