Last active
September 17, 2015 05:43
-
-
Save bradurani/dcada3b13160cd09c8ef to your computer and use it in GitHub Desktop.
Function Factory Before
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
function getTotal(lineItems, state) { | |
let subtotal = lineItems.reduce((total, lineItem) => { | |
return total += lineItem.total | |
}); | |
return subtotal + salesTax(state, subtotal)); | |
} | |
function salesTax(state, subtotal) { | |
switch(state) { | |
case 'ak': return 0; | |
case 'co': return .029 * subtotal; | |
case 'ca': return .075 * subtotal; | |
} | |
} | |
getTotal(lineItems, 'ca'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment