Given an integer n, return the sum of all digits in the absolute value of n.
For example, sumOfDigits(-123) returns 6 because |-123| = 123 and 1 + 2 + 3 = 6.
n = 1236n = -45615n = 00-10^9 <= n <= 10^9n is an integer.Run your code to see results
Use Cmd+Enter to run