I want to compare the start date of the curr_item array based on index, but im getting this particular error at the arrow marked line.Im not sure what the issue is :(
0: Object start_time: "2021-10-27T13:30:00.000+05:30" end_time: "2021-10-27T13:45:00.000+05:30" 1: Object start_time: "2021-10-27T13:46:00.000+05:30" end_time: "2021-10-27T14:00:00.000+05:30" 2: Object start_time: "2021-10-27T14:00:00.000+05:30" end_time: "2021-10-27T15:02:00.000+05:30"
for (let index = 0; index < possible_slots; index++) {
if (
curr_time.toMillis() ===
-----> DateTime.fromISO(curr_item[index].start_time).toMillis() <-----
) {
slotlist.push({
start_time: DateTime.fromISO(curr_item[index].start_time).toISO(),
end_time: DateTime.fromISO(curr_item[index].end_time).toISO(),
name: `asd`
});
} else {
slotlist.push({
start_time: DateTime.fromISO((curr_item[index]).start_time).toISO(),
end_time: DateTime.fromISO(curr_item[index].end_time).toISO(),
hole: `true${index}`
});
curr_time = DateTime.fromISO(slotlist[slotlist.length - 1].end_time);
}
curr_item[index] = curr_item[index + 1];
}
Error: Cannot read properties of undefined (reading 'start_time')
There can be only two reasons for this: