min max sum hackerrank solution in javascript
let maxVal = 0;
let minVal = 0;
let max = arr.reduce((a,b)=>{
return Math.max(a,b)
})
let min = arr.reduce((a,b)=>{
return Math.min(a,b)
})
let minIndex = arr.indexOf(min)
let maxIndex = arr.indexOf(max)
let maxArr = arr
maxArr.splice(maxIndex , 1)
let minSum = 0;
for(let key in maxArr){
minSum += maxArr[key]
}
let maxSum = (minSum -min)+ max
console.log(minSum + ' ' + maxSum)
// Paste this code inside the function.