by lscharen · 2mo ago · 0 comments
total = calculateOrderTotal(user.order);
if (user.isPremiumMember) {
total = total * 0.9; // 10% discount
versus total = calculateOrderTotal(user.order);
discount = calculateDiscount(user); // Returns 0.9 or 1.0
total = total * discount; return 1 - user.isPremiumMember * 0.1;
would also cut it. total = calculateOrderTotal(user.order);
total = total * user.discount; total = calculateOrderTotal(user.order);
total *= user.discount;
or: return
calculateOrderTotal(user.order)
* user.discount;