How far from free shipping
- O(1) · Trivial
- Free
- Python
- JavaScript
- operations
- conditionals
Problem
The store ships for free once your order reaches a certain amount. Take cart, what you have so far, and minimum, the amount that unlocks free shipping, and return how much more you need.
With 180 in the cart and a minimum of 500, you need 320 more.
If you already got there, or went past it, you need nothing: return 0, never a negative number.
Examples
180, 500 → 320
Right on the minimum
500, 500 → 0
Empty cart
0, 300 → 300
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def still_needed(cart, minimum):
passJavaScript
function stillNeeded(cart, minimum) {
}Solve this challenge
It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.