Generated documentation for calculateSubtotal
source lines 1 to 5calculateSubtotal
Calculates a discounted subtotal from a given amount.
calculateSubtotal(amount, discountRate = 0.1)Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
amount | number | required | The original amount before discount |
discountRate | number | 0.1 | The discount rate as a decimal (default 10%) |
Returns
number - The amount after applying the discount.
Example
calculateSubtotal(100); // Returns 90 (10% off)
calculateSubtotal(100, 0.25); // Returns 75 (25% off)Notes
- Uses a simple percentage calculation:
amount - (amount * discountRate) - Default discount of 10% is applied if no rate is specified
Generate this for your repo
Paste a public GitHub repository. No signup.
Sample. The snippet and its docs are the saved demo result in lib/demoSamples.ts, the same one the /demo page shows. Nothing on this page is generated live.