Spot the bug in the discount policy

from SOLID principles
TypeScript 6 intermediate 4 min 1 issue to find

Find the substitution bug in this implementation, whose interface promises a discount for every valid order.

JavaScript
class VipOnlyDiscount {
  discountFor(order) {
    if (order.customerKind !== 'vip') {
      throw new Error('VIP customers only');
    }
    return order.subtotal * 0.1;
  }
}
Open in playground
Report an error