Function Parameters

Parameters
πŸ‘¨β€πŸ’Ό Perfect! You've created reusable, type-safe functions with clear inputs.
πŸ¦‰ Notice how the parameter and return types serve as documentation:
function applyDiscount(price: number, discountPercent: number): number
Just from reading this signature, you know:
  • It takes a price and a percentage
  • It returns a number
  • You can't accidentally pass a string
This is the power of TypeScriptβ€”self-documenting code that catches mistakes at compile time, not runtime.

Please set the playground first

Loading "Function Parameters"
Loading "Function Parameters"