Калькулятор скидки JavaScript

const {afterDiscount,beforeDiscount, discountAmount, percentage} = discountCalculate(500,10)
const discountCalculate = (amount, percentage) => {
    let beforeDiscount = parseFloat(parseFloat(amount).toFixed(2))
    let discountAmount = parseFloat(((beforeDiscount * percentage) / 100).toFixed(2))
    let afterDiscount = (beforeDiscount - discountAmount)
    return { afterDiscount, beforeDiscount, discountAmount, percentage }
};
CodePadding