• + 0 comments

    Typescript:

    let sum = 0;
    let minVal = Infinity; 
    let maxVal = 0;
    for (let i of arr) {
       sum += i;
       if (i < minVal) minVal = i;
       if (i > maxVal) maxVal = i;
    }
    console.log(sum - maxVal, sum - minVal);