[Solved] calculate the sum of all the digits of number till you get a single digit in java script r give idea to improve below program [closed]


Javascript Function

function DigitSum(var num)
{
 var sum = 0;

 while (num > 0)
{
   sum += parseInt(num % 10);

   num = parseInt(num/10);
}
if (sum > 9)
{
   sum = DigitSum(sum);
}
  return sum;
}

3

solved calculate the sum of all the digits of number till you get a single digit in java script r give idea to improve below program [closed]