Did not understant this operator on array

Tell us what’s happening:
Describe your issue in detail here.

  **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 = [...state, "ADD_TO_DO"]
  default:
    return state;
}
};

const addToDo = (todo) => {
return {
  type: 'ADD_TO_DO',
  todo
}
}

const store = Redux.createStore(immutableReducer);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0

Challenge: Use the Spread Operator on Arrays

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.

You are using the spread syntax correctly you are just not adding the todo after it.

Looking at this object returned from the action creator…

return {
  type: 'ADD_TO_DO',
  todo
}

…if the type is action.type what is the todo?

return [...state, addTheTodoHere]

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.