arindam-product-price

1.0.0 • Public • Published

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'));

Package Sidebar

Install

npm i arindam-product-price

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.1 kB

Total Files

4

Last publish

Collaborators

  • devarindam