Created
November 1, 2010 18:06
-
-
Save mklabs/658624 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function calculateTotal(baseTotal, tip, tax, fee) { | |
| // convert the tip to a number using base 10; | |
| // allow for a NaN result from parseFloat | |
| tip = parseFloat(tip) || 0; | |
| // don't allow a negative tip | |
| if (tip < 0) { tip = 0; } | |
| return baseTotal + tip + tax + fee; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment