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

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?.