Mini-Max Sum

  • + 0 comments

    function miniMaxSum(arr: number[]): void { let totalSum = 0; let minValue = Infinity; let maxValue = -Infinity;

    for (const num of arr){
        totalSum += num;
    
        if(num < minValue){
            minValue = num;
        }
    
        if(num > maxValue){
            maxValue = num;
        }
    }
    
    console.log(``${totalSum - maxValue} $`{totalSum - minValue}`)
    

    }