I am working with an Array and need to retrieve information for a specific day:
var today = new Date();
var Days = ['Sunday','Monday',"Tuesday","Wednesday","Thursday","Friday","Saturday"];
var Day = Days[today.getDay()];
alert(Schedule.Day[5].Subject);
When I directly input "Monday" into the alert, it works perfectly. However, when using the variable it does not work.
This is a portion of my array:
var Schedule = {
Monday: [ {
Subject: "0",
Packing: "0"
},
{
Subject: "1",
Packing: "1"
},
{
Subject: "2",
Packing: "2"
},
{
Subject: "3",
Packing: "3"
},
{
Subject: "4",
Packing: "x"
},
{
Subject: "xx5",
Packing: "xx"
},
{
Subject: "break",
Packing: "break"
},
{
Subject: "Sports",
Packing: "Sports bag"
},
{
Subject: "Sports",
Packing: "Sports bag"
}
],
[.......]
Thank you!