I've been working on a function for a web page that should display information from a JSON object depending upon two attributes, the attendance day and start time. The JSON and function are as follows is as follows:
var courses = [{
"dept": "CSC",
"id": "3380",
"instructor": "Douglas",
"Location": "012 Lockett",
"Start_Time": "8:00",
"End_Time": "9:30",
"Attendance": "Monday"
}, {
"dept": "CSC",
"id": "3380",
"instructor": "Douglas",
"Location": "012 Lockett",
"Start_Time": "10:30",
"End_Time": "11:30",
"Attendance": "Monday"
}, {
"dept": "CSC",
"id": "3380",
"instructor": "Douglas",
"Location": "012 Lockett",
"Start_Time": "12:30",
"End_Time": "1:30",
"Attendance": "Wednesday"
}];
function plotCourse() {
var i;
for (i = 0; i < courses.length; i++) {
var course = courses[i];
console.log(course);
if (course.Attendance == "Monday" && course.Start_Time == "10:30") {
alert(course.Attendance);
alert(course.Start_Time);
}
}
}
I'm using alert() for testing purposes. However, I don't seem to get a returned value, and I'm a bit stumped and what may be going on.
Thanks in advance.
plotCourse()function. You just define it.