Never Mutate State: Object.assign not working

Help, why can’t i make this right, i tried not to use concat and other array functions, just want to use the Object.assign() why it isn’t working?

Your code so far

const ADD_TO_DO = 'ADD_TO_DO';

// A list of strings representing tasks to do:
const todos = [
  'Go to the store',
  'Clean the house',
  'Cook dinner',
  'Learn to code',

const immutableReducer = (state = todos, action) => {
  switch(action.type) {
    case ADD_TO_DO:
      // don't mutate state here or the tests will fail
      return Object.assign({},state,action.todo);
      return state;

// an example todo argument would be 'Learn React',
const addToDo = (todo) => {
  return {
    type: ADD_TO_DO,

const store = Redux.createStore(immutableReducer);

Your browser information:

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

Link to the challenge:

The instructions state

See if you can find a way to return a new array with the item from action.todo appended to the end.

Instead, your code above attempts to return an object.

1 Like