Is it possible to insert data into a predefined JSON variable using a variable? Here are the predefined JSON variables:
data(){
return {
dataMON: [],
dataTUE: [],
dataWED: [],
dataTHU: [],
dataFRI: []
}
}
And this is the data that needs to be added:
getTimeTable() {
var db = firebase.firestore();
var date = new Date();
var weekday = new Array(5);
weekday[0] = "monday";
weekday[1] = "tuesday";
weekday[2] = "wednesday";
weekday[3] = "thursday";
weekday[4] = "friday";
weekday.forEach(day => {
var dayLowerCase = day.slice(0, 3);
var dayUpperCase = dayLowerCase.toUpperCase();
var tmpTable = {
period: doc.id,
course: fullTempTable.fach,
teacher: fullTempTable.lehrer,
room: fullTempTable.raum
};
this.day.[dayUpperCase].push(tmpTable);
});
}
The issue arises when trying to use day[dayUpperCase] as it searches for the object named dayUpperCase. Is it possible to utilize variables in this situation?