Search
 
SCRIPT & CODE EXAMPLE
 

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;
  
}
Comment

Sum of Digits / Digital Root

function digital_root(n) {
  return (n - 1) % 9 + 1;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to convert decimal to roman in javascript 
Javascript :: Adding User And Hashed Password In ExpressJS 
Javascript :: check if browser supports Local Storage 
Javascript :: threemeshphonematerial url image three js 
Javascript :: js push array 
Javascript :: js reduce 
Javascript :: javascript unique array 
Javascript :: Select HTML elements by CSS selectors 
Javascript :: js check data type 
Javascript :: how to get json response from rest api in node js 
Javascript :: delete duplicate array javascript 
Javascript :: how to get the uppert triangular matrix out of a matrix matlab 
Javascript :: javascript arreglos 
Javascript :: selected value 
Javascript :: how to split an array into two javascript 
Javascript :: change module name react native android studio 
Javascript :: node fs existssync 
Javascript :: laravel vue global function 
Javascript :: js delete all cookies 
Javascript :: context api 
Javascript :: javascript focus on contenteditable not working 
Javascript :: javascript set style attribute 
Javascript :: how to append response header in node 
Javascript :: remove id from array javascript 
Javascript :: js knex migration 
Javascript :: math js 
Javascript :: === javascript 
Javascript :: Error: ENOENT: no such file or directory, lstat ode_modules@react-navigationcoresrcgetStateFromPath.tsx 
Javascript :: set time out 
Javascript :: reactjs lifecycle class components 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =