• + 1 comment
    function miniMaxSum(arr: number[]): void {
        // Write your code here
        let min = Infinity, max = -Infinity, totalSum = 0;
        
        for (let i = 0; i < arr.length; i++) {
          const current = arr[i];
          totalSum += current;
    
          if (current > max) {
            max = current;
          }
    
          if (current < min) {
            min = current;
          }
        }
    
        console.log(totalSum - max, totalSum - min)
    }