param { number [ ] } array return { number } function FindGreatestSum ( array ) { if ( ! array || array . length < 1 ) { return 0 ; } else { let sum = array [ 0 ] ; let max = array [ 0 ] ; for ( let i = 1 ; i < array . length ; i ++ ) { if ( sum < 0 ) { sum = array [ i ] ; } else { sum = sum + array [ i ] ; } max = sum > max ? sum : max ; } return max ; } } export { FindGreatestSum } ;