How would you approach writing a JavaScript function to identify the maximum sum of a contiguous subarray within an array of integers?

Free for the first 3 answer contributors

Interview question asked to Frontend Engineers interviewing at Dell Technologies, GoDaddy, Electronic Arts and others: How would you approach writing a JavaScript function to identify the maximum sum of a contiguous subarray within an array of integers?.