Skip to content

Commit 3fbd239

Browse files
authored
Create 1491-average-salary-excluding-the-minimum-and-maximum-salary.js
1 parent 7d24af7 commit 3fbd239

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @param {number[]} salary
3+
* @return {number}
4+
*/
5+
const average = function(salary) {
6+
const sum = salary.reduce((ac, e) => ac + e, 0)
7+
const min = Math.min(...salary), max = Math.max(...salary)
8+
const n = salary.length
9+
10+
return (sum - min - max) / (n - 2)
11+
};

0 commit comments

Comments
 (0)