5 XP challenge
Calculate a Two-Tier Price
very easy
Build it yourself · 3 min
1 Learn2 Predict3 Solve
TaskYour mission
Return the total price of quantity units. The first allowance units each cost firstRate; later units each cost extraRate. All inputs are integers from 0 to 20.
Examples
| Input | Return |
|---|---|
quantity = 3, allowance = 5, firstRate = 2, extraRate = 4 | 6 |
quantity = 5, allowance = 5, firstRate = 2, extraRate = 4 | 10 |
Your code
Write your answer inside Solution, then use return to send it back.
Ln 1, Col 1
JavaScript
Try examples runs the public examples. Check my code checks your full answer and saves your completion.