const notes = (state = [], action) => {
  let notes, index, categoryGroupIndex;
  switch (action.type) {
    case 'ADD_NOTE':
      notes = [...state];
      index = notes.map(function(el) { return el.categoryTitle; }).indexOf(action.category);
      if (notes[index]) {  
        notes[index].categoryNotes.push({
          title: action.title,
          description: action.description
        });
      }
      return notes;
    case 'EDIT_NOTE':
      categoryGroupIndex = state.map(function(el) { return el.categoryTitle; }).indexOf(action.category);
      notes = [...state];
      notes[categoryGroupIndex].categoryNotes[action.index] = {
        title: action.title,
        description: action.description
      };
      return notes;
    case 'DELETE_NOTE':
      categoryGroupIndex = state.map(function(el) { return el.categoryTitle; }).indexOf(action.category);
      notes = [...state];
      notes[categoryGroupIndex].categoryNotes.splice(action.index, 1);
      return notes;
    default:
      return state;
  }
}

export default notes;

@@ -49,15 +49,8 @@
 tes,
- index,
  cat
@@ -66,16 +66,16 @@
 pIndex;%0A
+
   switch
@@ -144,17 +144,30 @@
 ;%0A      
-i
+categoryGroupI
 ndex = n
@@ -264,17 +264,30 @@
 tes%5B
-i
+categoryGroupI
 ndex%5D) %7B
   %0A 
@@ -282,18 +282,16 @@
 ndex%5D) %7B
-  
 %0A       
@@ -297,17 +297,30 @@
   notes%5B
-i
+categoryGroupI
 ndex%5D.ca

reduce number of variables