Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Sum of Digits / Digital Root

// codewars:Sum of Digits / Digital Root
function digitalRoot(n) {
  
   let result = 0;
  String(n).split('').map(num => {
    result += Number(num);
  });
  return result >= 10 ? digitalRoot(result) : result;
  
}
 
PREVIOUS NEXT
Tagged: #Sum #Digits #Digital #Root
ADD COMMENT
Topic
Name
3+5 =