Aug 31, 2018 · 1 min read
I suppose there is a bug in the string.length > 1 loop, you should return sum unless you will always get 0
function add(string) {if (string.length > 1) {const list = string.split(',')let sum = 0;for (let i = 0; i < list.length; i++) {sum += parseInt(list[i]);}return sum} else if (string.length == 1) {return parseInt(string);} else {return 0;}}
