HOME

Use the checkDiscount function

Customers can use a discount code to reduce the price of their purchase. Valid discount codes and their value (in pounds) are stored in a global two-dimensional (2D) array with the identifier discount. The following table shows part of this 2D array.

PVFC710
CPU55
BGF215

For example, discount[2,0] holds discount code BGF2 and discount[2,1] holds the discount of 15 pounds. A function searches through the 2D array and applies the discount to the price. The price and discount code are passed in as parameters.

Construct the algorithm answer dragging &dropping and reordering lines from the left to the right.

Jumble the blocks! Try your code!