Create a simple calculator function add (or Add) which takes a string as input and return an integer as output.
Create a simple calculator function add (or Add) which takes a string as input and return an integer as output.
Examples:
• add("1,2,3") => 6
• add("") => 0
• add("42") => 42
• add("-1,1") => 0 // negative numbers is extra, crash or ignore if you like. 😉Wink
• add("1 3 5") => 9 // whitespace as separator is extra, crash if you like.
Focus: Make an effort to keep your code, methods and functions as pure as you can. Meaning as close to mathematical functions, only using the inputs to the function to calculate the output value and avoiding side effects. The means separating logic from IO.