doc: add getBasketTotal method

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