Answers for "min max sum hackerrank solution in javascript"

0

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.
Posted by: Guest on October-19-2021

Code answers related to "min max sum hackerrank solution in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language