Hi guys,
I’m trying to create a function that takes an integer input, adds each digit together, and if there are more than 1 digit, then do it again and again until there is only one.
Example:
Input = 456
~ 4+5+6=15
~ 1+5 = 6
so the function would return 6.
My algorithm seems to work, as tested by alert() messages, but somehow at the final step of returning the value, everything falls apart.
The solution seems so simple that I literately ran out of ideas to even test why it doesn’t work. Please help.
I put the two questions I have as comments in the JSFiddle code, here’s the link:
https://jsfiddle.net/nvhctqa0/2/
Thanks in advance