doc: add getBasketTotal method

This commit is contained in:
Leon Xu committed 2022-05-05 21:37:10 -07:00
1 parent 27462887ac
commit d64671d0f5
1 file changed
+3
+3
View File
@@ -2,6 +2,9 @@ export const initialState = {
basket: [], basket: [],
}; };
export const getBasketTotal = (basket) =>
basket?.reduce((amount, item) => item.price + amount, 0);
const reducer = (state, action) => { const reducer = (state, action) => {
switch (action.type) { switch (action.type) {
case "ADD_TO_BASKET": case "ADD_TO_BASKET":