const getDiscountPrice = (amount, couponCode) => {
switch (couponCode) {
case 'DIJFNC':
return amount * 0.8
case 'XPFJVM':
return amount * 0.75
case 'FJDPCX':
return amount * 0.5
default:
return amount * 1
}
}
const getDiscountPrice = (amount, couponCode) => {
let discount = 1
if (couponCode === 'DIJFNC') discount = 0.8
if (couponCode === 'XPFJVM') discount = 0.75
if (couponCode === 'FJDPCX') discount = 0.5
return amount * discount
}
const discountMultiplier = {
'DIJFNC': 0.8,
'XPFJVM': 0.75,
'FJDPCX': 0.5
}
const getDiscountPrice = (amount, couponCode) => amount * discountMultiplier[couponCode]
4 Things You Have to Unlearn to Become a Better Programmer