Skip to content

Commit 5f8537a

Browse files
committed
fix checks in getCurrentClassperiodIndex()
1 parent 545e744 commit 5f8537a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

classtime.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,18 +326,19 @@ return "on <strong>" + currentDate.toLocaleString('en-US', { weekday: 'short', m
326326
* @returns an index for looking up the current class period, or -1 if there is no school today
327327
*/
328328
function getCurrentClassPeriodIndex() {
329-
if (!isNoSchoolDay()) {
330-
//using for over forEach() because we are breaking out of the loop early
331-
for (let i = 0; i < data.schedules[currentScheduleIndex].classes.length; i++) {
332-
if (checkStartTime(data.schedules[currentScheduleIndex].classes[i]) && checkEndTime(data.schedules[currentScheduleIndex].classes[i])) {
333-
return i
334-
break;//not sure if this is necessary so I included it anyway
335-
}
336-
}
337-
} else {
338-
//if execution reaches here, no class periods are in session, so therefore school must be out
329+
if (isNoSchoolDay()) {
330+
//return immediately if there is no school today
339331
return -1
340332
}
333+
334+
//using for over forEach() because we are breaking out of the loop early
335+
for (let i = 0; i < data.schedules[currentScheduleIndex].classes.length; i++) {
336+
if (checkStartTime(data.schedules[currentScheduleIndex].classes[i]) && checkEndTime(data.schedules[currentScheduleIndex].classes[i])) {
337+
return i
338+
break;//not sure if this is necessary so I included it anyway
339+
}
340+
}
341+
return -1
341342
}
342343

343344
/**

0 commit comments

Comments
 (0)