← Back to challenges

Adding Numbers in a String

JavaScriptHardlanguage_fundamentalsnumbers

Instructions

Given a string of numbers separated by a comma and space, return the total sum of all the numbers.

Examples

addNums("2, 5, 1, 8, 4") ➞ 20

addNums("1, 2, 3, 4, 5, 6, 7") ➞ 28

addNums("10") ➞ 10

Notes

  • Numbers will always be separated by a comma and space.
  • Your function should accept negative numbers.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Return the Highest and Lowest Numbers