JSFiddle - React, Tailwind, and code Playground

by Dmitri Ganenco

JavaScript

var a1 = [{
    id: 'Monday',
    slots: [{
        end: "05:00:00 PM",
        start: "08:00:00 AM"
      },
      {
        end: "04:00:00 PM",
        start: "03:00:00 AM"
      }
    ]
  },
  {
    id: 'Tuesday',
    slots: [{
      end: "05:00:00 PM",
      start: "08:00:00 AM"
    }]
  }
];

var c1 = [{
    id: 'Monday',
    slots: [{
        end: "05:00:00 PM",
        start: "08:00:00 AM"
      },
      {
        end: "04:00:00 PM",
        start: "03:00:00 AM"
      }
    ]
  },
  {
    id: 'Tuesday',
    slots: [{
      end: "05:00:00 PM",
      start: "08:00:00 AM"
    }]
  }
];

var b1 = [{
    id: 'Monday',
    slots: [{
        end: "04:00:00 PM",
        start: "06:00:00 AM"
      },
      {
        end: "03:00:00 PM",
        start: "02:00:00 AM"
      }
    ]
  },
  {
    id: 'Tuesday',
    slots: [{
      end: "05:00:00 PM",
      start: "08:00:00 AM"
    }]
  },
  {
    id: 'Wednesday',
    slots: [{
      end: "05:00:00 PM",
      start: "08:00:00 AM"
    }]
  }
];

function compareArrays(a, b) {
  let result = true;
  if (a.length !== b.length) {
    result = false;
  }else{
		a.forEach(el => {
			if(b.indexOf(el.id) === -1 || el.slots.length !== b[el.id].slots.length){
				result = false;
			}else{
			let bSlots = b[el.id].slots.length;
				el.slots.forEach((slot, slotIndex) => {
					Object.keys(slot).forEach(key => {
						if(slot[key] !== bSlots[slotIndex]){
							result = false;
						}
					})
				});
			}
		})
	}
  return result;
}

console.log(compareArrays(a1, c1));