Redux: Remove an Item from an Array

Hey guys I have a question for this challenge. I can’t seem to pass the last test which requires the state to not be mutated. However I’m printing the state and arr values in my local IDE and the state prints its original values and does not appear to mutate. What am I doing wrong here?
This is my code

const immutableReducer = (state = [0,1,2,3,4,5], action) => {
    switch(action.type) {
    case 'REMOVE_ITEM':
      // don't mutate state here or the tests will fail
      let arr =[...state].filter(x =>x !== action.index);
    return arr;
      return state;

const removeItem = (index) => {
  return {
    type: 'REMOVE_ITEM',

const store = Redux.createStore(immutableReducer);

Thanks guys!

challenge link

Heya - the issue here doesn’t seem to be with mutating the state array - you used the spread operator correctly to create a copy. I think you may want to take a look at what your .filter method is doing - is the “x” variable referencing the index of the array or is it referencing the actual value at each index? It also might be confusing in this specific example because the array values in the given state match their index values, but that’s not usually going to be the case.

Hope this is helpful!