Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

discount calculator 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 }
};
 
PREVIOUS NEXT
Tagged: #discount #calculator #javaScript
ADD COMMENT
Topic
Name
6+2 =