I am newbie.
I want to make small app which will calculate the sum of all the digits of a number.
For example, if I have the number 2568, the app will calcul
let's try recursivity
function sumDigits(n) { if (n < 10) return n return sumDigits(n % 10 + sumDigits(Math.floor(n / 10))) } sumDigits(2) // 2 sumDigits(2568) // 3