Task of Challenge #17/54
Calculate the sum of digits of a positive integer number.
The integer 1235321
The solution is pretty straightforward. You need to separate the digits to loop over them and add them to a sum.
You can do it by a conversion to a string because this is nothing more than a char array under the hood.
You can take advantage of this knowledge by iterating over the array with a for-of-loop. While looping you add up the sum and finally returning the sum to the caller.
This is the printout after the sum was created.
Pro-Tip: If you want to write better code, try to accomplish this task with the reduce() and map() functions from the Array.prototype.