Skip to content

Commit

Permalink
Update main.js to handle multiple hours course merge logic, fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
ecwu authored May 12, 2024
1 parent 20841b3 commit e41e46a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ function mergeCourse(course_array){
continue;
}
if (new_array[new_array.length-1][0][0] === course_array[i][0][0] && new_array[new_array.length-1][0][1] === course_array[i][0][1]){
new_array[new_array.length-1][2] = [new_array[new_array.length-1][2], course_array[i][2]]
if (new_array[new_array.length-1][2].length >= 2) {
temp = new_array[new_array.length-1][2]; // handling the case when the course session is more than 2 hours
temp[temp.length] = course_array[i][2];
new_array[new_array.length-1][2] = temp;
} else {
new_array[new_array.length-1][2] = [new_array[new_array.length-1][2], course_array[i][2]];
}
}else{
new_array.push(course_array[i])
}
Expand Down

0 comments on commit e41e46a

Please sign in to comment.