简体   繁体   中英

Why doesn't my console show a result based on code below

Why doesn't my console show the results of the function markTipCalculator? The last line of code I would have thought would have called that function and returned a result in my console.

function markTipCalculator(){
markBills = [77, 375, 110, 45];
let markSmallBillPercent = .20;
let markMediumBillPercent = .10;
let markLargeBillPercent = .25;
let markSmallTip = 0
let markMediumTip = 0
let markLargeTip = 0
    for (i of markBills){
        let markBillAmts = i
        switch (true){
            case markBillAmts < 100:
                markSmallBillAmount = markBillAmts * markSmallBillPercent;
                markSmallTip += markSmallBillAmount;
               break;
            case markBillAmts >= 100 && markBillAmts<= 300:
                markMediumBillAmount = markBillAmts * markMediumBillPercent;
                markMediumTip += markMediumBillAmount;
               break;
            case markBillAmts > 300:
                markLargeBillAmount = markBillAmts * markLargeBillPercent;
                markLargeTip += markLargeBillAmount;
               break;
            default: 
            console.log('We have an error somewhere');
        } 
        };
       return (markSmallTip + markMediumTip + markLargeTip)
};
markTipCalculator();

You don't see anything in your console because you aren't logging anything to your console. Try console.log(markTipCalculator())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM