C#
public decimal GetDiscountPercentage(decimal sellPrice, decimal discountPrice)
=> sellPrice == 0 ? 0 : Math.Abs((((discountPrice - sellPrice) / sellPrice) * 100));
public decimal GetDiscountPrice(decimal sellPrice, byte discountPercentage)
=> discountPercentage == 0 ? 0 : sellPrice == 0 ? 0 : sellPrice - (sellPrice * discountPercentage / 100);
JS
var getDiscountPercentage = function (sellPrice, discountPrice) {
return sellPrice === 0 ? 0 : Math.abs((((discountPrice - sellPrice) / sellPrice) * 100));
}
var getDiscountPrice = function (sellPrice, discountPercentage) {
return discountPercentage === 0 ? 0 : sellPrice === 0 ? 0 : sellPrice - (sellPrice * discountPercentage / 100);
}
JS - ES6
const getDiscountPercentage = (sellPrice, discountPrice)
=> sellPrice === 0 ? 0 : Math.abs((((discountPrice - sellPrice) / sellPrice) * 100));
const getDiscountPrice = (sellPrice, discountPercentage)
=> discountPercentage === 0 ? 0 : sellPrice === 0 ? 0 : sellPrice - (sellPrice * discountPercentage / 100);