var average = function(salary) { let mix = salary[0] let max = salary[0] let sum = 0 if ( salary.length >= 3 ) { for(let i = 0 ; i<salary.length; i++) { sum += salary[i] if(salary[i] > max) { max = salary[i] } if(salary[i]< mix){ mix = salary[i] } } return (sum-max-mix) / (salary.length-2) }else { return 0 } } console.log('这是',average([3,5,7]))