Need help for React and Redux: Extract State Logic to Redux

I am working on the React and Redux challenges. On the third challenge ‘extract state logic to redux,’ I am stuck. I think my code is pretty much the same as the solution but it’s not passing the test.

const ADD = "ADD";

const addMessage = (message) => {
  return {
    type: ADD,
    message: message
  };
};

const messageReducer = (action, Prestate=[]) => {
  switch(action.type) {
    case ADD:
      return [...Prestate, action.message];
      break;
      
    default:
      return Prestate;
  }
};
const store = Redux.createStore(messageReducer);

and the tests not passed

1 Like

Hi @q109037. Welcome to FCC.
The problem is in the order of parameters to your reducer. It should be (Prestate=[], action) not (action, Prestate=[])

1 Like

Thank you so much!!!