https://github.com/depakmurthy/incubyte-string-calculator
Start with the simplest test case of an empty string and move to one and two numbers. Input: a string of comma-separated numbers. Output: an integer, sum of the numbers
https://github.com/depakmurthy/incubyte-string-calculator
Last synced: 2 months ago
JSON representation
Start with the simplest test case of an empty string and move to one and two numbers. Input: a string of comma-separated numbers. Output: an integer, sum of the numbers
- Host: GitHub
- URL: https://github.com/depakmurthy/incubyte-string-calculator
- Owner: depakmurthy
- License: mit
- Created: 2024-08-22T07:40:30.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-08-22T07:45:10.000Z (9 months ago)
- Last Synced: 2025-01-21T08:25:38.537Z (4 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# incubyte-string-calculator
Start with the simplest test case of an empty string and move to one and two numbers.
Input: a string of comma-separated numbers.
Output: an integer, sum of the numbers# Examples:
Input: “”, Output: 0
Input: “1”, Output: 1
Input: “1,5”, Output: 6Allow the add method to handle any amount of numbers.
Allow the add method to handle new lines between numbers (instead of commas). ("1\n2,3" should return 6)# Support different delimiters:
To change the delimiter, the beginning of the string will contain a separate line that looks like this: "//[delimiter]\n[numbers…]".
For example, "//;\n1;2" where the delimiter is ";" should return 3.Calling add with a negative number will throw an exception: "negative numbers not allowed ".
If there are multiple negative numbers, show all of them in the exception message, separated by commas.