return totalPrice > x;
That returns a boolean value of true or false, and the calculated
DiscountPrice
value is thrown away after it is calculated. Also, why are you passing in
products
and
totalQuantity
since you do not use either value anywhere in your calculation.
Think about the simple steps needed to do this:
the function only needs to know the current total price, and the steps are something like:
1. set newprice = totalprice.
2. if totalprice > x then set newprice = totalprice * .90
3. return newprice // if totalprice is less than x, then original total will be returned