// sum the values of the string "a" e.g. 3,2,4,1 = 10 function GetSum(a) { // split the passed string into new array var nums = a.split(','); var total = 0; // loop and build total, converting strings to numbers on-the-fly for(var i = 0; i < nums.length; i++) total += Number(nums[i]); return total; }