Created
April 20, 2010 19:18
-
-
Save rentpath/372925 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given an original price of $5.00 | |
# When I order one my total price should be $5.00 | |
# When I order two my total price should be $8.35 | |
# When I order three my total price should be $11.70 | |
function calculate_price(quantity, orig_price) { | |
if (quantity == 1) { | |
price = orig_price * quantity; | |
} else { | |
price = orig_price + ((quantity - 1) * orig_price * 67 / 100); | |
} | |
return price; | |
} | |
console.log(calculate_price(1, 5.00)); | |
console.log(calculate_price(2, 5.00)); | |
console.log(calculate_price(3, 5.00)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment