how to update specific key of an object in reducer code example

Example: how to update specific key of an object in reducer

case COMPLETE_TODO: {
  const index = state.todos.findIndex(todo => todo.id === action.payload); //finding index of the item 
  const newArray = [...state.todos]; //making a new array 
  newArray[index].completed = true//changing value in the new array 
  return {   ...state, //copying the orignal state  
          todos: newArray, //reassingning todos to new array 
         }
}