Challenge 2: Sum of Digits in a String

Given a string containing numbers, calculate the sum of those numbers.

Problem Statement

Implement a function that takes a variable testVariable, which contains a string of digits, and prints the sum of those digits.


A variable testVariable containing a string of digits.


Sum of the digits in the string.

Sample Input


Sample Output


Try it Yourself

Try this challenge yourself before examining the solution. Good luck!

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.