From 8a5825d52271d712ec7c8348447d433067e13ef2 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 13 Sep 2018 14:18:56 -0400 Subject: DONE --- stepped-solutions/FINISHED/frontend/lib/calcTotalPrice.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 stepped-solutions/FINISHED/frontend/lib/calcTotalPrice.js (limited to 'stepped-solutions/FINISHED/frontend/lib/calcTotalPrice.js') diff --git a/stepped-solutions/FINISHED/frontend/lib/calcTotalPrice.js b/stepped-solutions/FINISHED/frontend/lib/calcTotalPrice.js new file mode 100644 index 0000000..4822468 --- /dev/null +++ b/stepped-solutions/FINISHED/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); +} -- cgit v1.3