diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-03-23 11:11:09 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-03-23 11:11:09 -0400 |
| commit | 4fb8969f6994d8414f388f583d8e270d4e4a67e9 (patch) | |
| tree | dad4cd0eeda0fdc71e4f925c263668763f2e4dff /frontend/lib/calcTotalPrice.js | |
| parent | fa16c52917305e21823294e3a4e384bfeae50da0 (diff) | |
ya
Diffstat (limited to 'frontend/lib/calcTotalPrice.js')
| -rw-r--r-- | frontend/lib/calcTotalPrice.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/frontend/lib/calcTotalPrice.js b/frontend/lib/calcTotalPrice.js new file mode 100644 index 0000000..4822468 --- /dev/null +++ b/frontend/lib/calcTotalPrice.js @@ -0,0 +1,6 @@ +export default function calcTotalPrice(cart) { + return cart.reduce((tally, cartItem) => { + if (!cartItem.item) return tally; + return tally + cartItem.quantity * cartItem.item.price; + }, 0); +} |
