loveapplejy / daily-algorithm

0 stars 0 forks source link

[HackerRank] Mini-Max Sum #4

Open loveapplejy opened 5 years ago

loveapplejy commented 5 years ago

https://www.hackerrank.com/challenges/mini-max-sum/problem

loveapplejy commented 5 years ago

function miniMaxSum(arr) { arr.sort((a, b) => a - b);

const minNum = arr.shift();
const maxNum = arr.pop();
const sum = arr.reduce((a, b) => a + b);

console.log(`${sum + minNum} ${sum + maxNum}`);

}