I have a variable named day. It contains the current day (i.e. "Wednesday") as a string. I also have an object called data. When I alert data.Wednesday it gives me the total count for that day.
alert(data.Wednesday); //alerts 2
I want the count for the current day (not the hard-coded Wednesday). My question is, how do I replace data.Wednesday
with data.day
. I obviously cant do data.day
because day isn't an element of the data object. Is there any way to do this? Thanks in advance.