🎯 What you'll practice: Reducer functions, dispatching, and useReducer vs useState.
1-A 2-B 3-B 4-B | 5 = switch 6 = state 7 = case "INCREMENT": return {...state, count: state.count+1}; 8 = dispatch({type:"INCREMENT"}); 9 = Because add/remove/clear are related actions that all modify the same cart state in different ways — centralising them in one reducer keeps the update logic in one place instead of scattered across multiple setState calls | 10 = function reducer(state,action){switch(action.type){case"ADD":return [...state,{id:Date.now(),text:action.text,done:false}];case"TOGGLE":return state.map(t=>t.id===action.id?{...t,done:!t.done}:t);case"DELETE":return state.filter(t=>t.id!==action.id);default:return state;}} const [todos,dispatch]=useReducer(reducer,[]);