[1, 2, Array[]]
function maxSubArray(nums){
let sum = -Infinity;
let max = -Infinity;
for(let i = 0; i < nums.length; i++){
if(sum < 0){
sum = nums[i];
}else{
sum += nums[i];
}
max = Math.max(sum, max);
}
return max;
}