
Review this JavaScript function for correctness: function average(values) { return values.reduce((sum, value) => sum + value, 0) / values.length; }. Define behavior for empty arrays and non-finite values, suggest a minimal fix, and provide three focused test cases.

