I am using an api to get holidays and their respective date. I took the values from the JSON file and made an array of arrays from it.
function getHolidays(){
(...)
var ulHoliday = new Array();
var txt = JSON.parse(this.responseText);
const holidays = txt.response.holidays;
for(hd of holidays){
let holidayName = hd.name;
let holidayDate = hd.date.iso;
ulHoliday.push({name: holidayName, date: holidayDate});
}
return ulHolidays;
}
When outputting the result the whole array-object (ulHolidays) seems fine but accesing items returns undefined. -_-
console.log(getHolidays()); // ulHolidays
console.log(getHolidays()[0].name); // undefined
^ The first one works but the secons one returns undefined. ^
This is the output when console-logging ulHolidays.
[]
0: {name: "Second Advent Sunday", date: "2020-12-06"}
1: {name: "Saint Nicholas Day", date: "2020-12-06"}
2: {name: "Third Advent Sunday", date: "2020-12-13"}
3: {name: "Remembrance Day for Roma and Sinti killed by Genocide", date: "2020-12-19"}
4: {name: "Fourth Advent Sunday", date: "2020-12-20"}
5: {name: "December Solstice", date: "2020-12-21T11:02:20+01:00"}
6: {name: "Christmas Eve", date: "2020-12-24"}
7: {name: "Christmas Day", date: "2020-12-25"}
8: {name: "Boxing Day", date: "2020-12-26"}
9: {name: "New Year's Eve", date: "2020-12-31"}
length: 10
__proto__: Array(0)