0 of 6 problems solved0%
5 of 6

Apply Discount (Callback Inference)

When a function parameter itself is a function, TypeScript can infer the parameter types of the passed-in callback from the target signature. That means callers don’t need to annotate arrow parameters explicitly.

You’ll write a small helper that applies a discount calculation.

Your Task

  • Complete the function applyDiscount(price: number, calculate: (p: number) => number): number.
  • Return the result of calling calculate(price).
  • Do not log; just return a number.

Examples

  • applyDiscount(100, p => p * 0.9) → 90
  • applyDiscount(50, p => p - 5) → 45