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.


