FunctionRacerProblemsRace

Sum of Digits in Text

BeginnerStringsPython, JavaScript, TypeScript, Java, C++

s is a text with letters, digits and symbols. Add up the value of every digit character in it (each digit counted on its own, so 45 adds 4 and 5). Return the total, or 0 if there are no digits.

Example 1

s "a1b22c"
returns 5

1 + 2 + 2 = 5.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems