โ† All coding problems

Sum of digits

EasyMaths

Return the sum of the digits of the non-negative integer n.

Function
function solve(n)
Example 1
n = 1234
โ†’ 10

Submit also runs 4 hidden tests, including edge cases.

console.log output is shown below