• + 0 comments
    function getMoneySpent(keyboards, drives, b) {
        /*
         * I know the solution is pretty straight forward, but I like my formating the best
         */
        let mostExpensivePurchase = -1;
        for (let i = 0; i < keyboards.length; i++){
            for (let j = 0; j < drives.length; j++){
                let sum = keyboards[i] + drives[j];
                if(sum <= b && sum > mostExpensivePurchase) mostExpensivePurchase = sum;
            }
        }
        return mostExpensivePurchase;
    
    }