Context: Seeking assistance in developing a timetable planner that can detect time clashes. Any guidance or support is greatly appreciated.
Specific Issue: Struggling to determine how to divide my array of objects into multiple arrays with a specific key repeated.
The dataset at hand:
let myCourses = [
{
course: "ee3001",
slots: [
{
day: "monday",
time: "0900-1100",
},
{
day: "tuesday",
time: "0930-1100",
},
{
day: "wednesday",
time: "1330-1530",
},
],
},
{
course: "ee3002",
slots: [
{
day: "monday",
time: "0900-1100",
},
{
day: "thursday",
time: "0930-1130",
},
],
},
{
course: "ee3003",
slots: [
{
day: "tuesday",
time: "0930-1100",
},
{
day: "wednesday",
time: "1330-1530",
},
{
day: "thursday",
time: "0930-1130",
},
],
},
];
Arrays I aim to divide it into:
let newarray = [
{
course: "ee3001",
slot: {
day: "monday",
time: "0900-1100",
},
},
{
course: "ee3001",
slot: {
day: "monday",
time: "1300-1400",
},
},
...
...
];
let newArray2 = // containing information on ee3002
let newArray3 = // containing information on ee3003
**Note:** The dataset should be dynamic, allowing users to input additional courses and timings.
- The rationale behind this division is so that I can utilize the Cartesian Product of arrays to identify all possible combinations.
- This will enable me to verify if there are any overlapping times within a given combination.
- Is there an improved method to address this issue?