Mini-Max Sum

  • + 0 comments

    I'm a newby but this one made me a bit happy... :)

    // Javascript function miniMaxSum(arr) { // Write your code here

    // console.log(arr)

    let totalArray = [];

    for(let i = 0; i < arr.length; i++){

    let sum = arr.reduce((acc, e) => acc + e,0) - arr[i];
    
    totalArray.push(sum);
    
     //console.log(sum)
    
    }
    

    console.log({Math.max(...totalArray)})

    }