5 XP challenge
Price after a Threshold
very easy
Build it yourself · 3 min
1 Learn2 Predict3 Solve
TaskYour mission
Return quantity * unitPrice, subtracting discount once if that total is at least threshold. quantity and unitPrice are 0 to 20; threshold is 1 to 100; discount is 0 to threshold.
Examples
| Input | Return |
|---|---|
quantity = 3, unitPrice = 5, threshold = 15, discount = 2total: 15 → 13. The result is 13. | 13 |
quantity = 2, unitPrice = 5, threshold = 15, discount = 2 | 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.