Course · Section 17: Modern JavaScript Development: Modules, Tooling, and Functional · Lecture 294: Declarative and Functional JavaScript Principles
Write a complete todo reducer driven by dispatched actions. Implement `todoReducer(state, action)` where state is an array of `{ text, done }`: - `{ type: 'add', text }` appends `{ text, done: false }`. - `{ type: 'toggle', index }` flips that todo's done. - `{ type: 'remove', index }` removes it. - `{ type: 'clearCompleted' }` drops all done todos. Unknown actions return the state unchanged. All updates immutable.
+ 1 hidden test run on Submit.
A reducer is a pure (state, action) function. Each case builds new immutable state, which is exactly how useReducer expects updates.
Run your code to see results.