Use-the-spread-operator-on-arrays

Tell us what’s happening:

What am I doing wrong for this challenge?

Your code so far


const immutableReducer = (state = ['Do not mutate state!'], action) => {
  switch(action.type) {
    case 'ADD_TO_DO':
      // don't mutate state here or the tests will fail
      return [...state, action.todo];
    default:
      return state;
  }
};

const addToDo = (todo) => {
  return {
    type: 'ADD_TO_DO',
    todo: 'some arbitrary task'
  }
};

const store = Redux.createStore(immutableReducer);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://beta.freecodecamp.org/en/challenges/redux/use-the-spread-operator-on-arrays

solved:

i modified the addToDo function. i didn’t realize that ‘todo’ was being passed through already as payload and not assigned to a particular key

1 Like