var sumArray = function(array) { var ans = 0; var sum = 0; //loop through the array. for (var i = 0; i < array.length; i++) { //this is to make sure that the sum is not negative. ans = Math.max(0, ans + array[i]); //set the sum to be overwritten if something ...