Shopify Interview Question

Adding some complexity to the initial problem after completing the code