Adding Numbers In A String

Published by Deep Xavier in

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("-12,  -13, 12, 17") ➞ 4

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.
Watch a quick demo on how Edabit works.