1.0.0 • Published 2 months ago

arindam-product-price v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

NPM Package

A simple npm package to get product price after discount

module.exports = {
    productPrice(orgPrice, discount, discountType = 'percentage') {
        let getOriginalPrice = parseFloat(orgPrice);
        let getDiscount = parseFloat(discount);
        if (discountType == 'flat') {
            return (getOriginalPrice - getDiscount).toFixed(2);
        }
        return (getOriginalPrice - ((getOriginalPrice * getDiscount) / 100)).toFixed(2);
    }
}

Install

npm i arindam-product-price

How to use

console.log("Percentage Discount = ", arindamProductPrice.productPrice(554.98, 22));
console.log("Flat Discount = ", arindamProductPrice.productPrice(554.98, 22, 'flat'));