I'm currently receiving this error with the following code:
TypeError: data.data.trek.days[current_day] is undefined
The problem I am having is that I need to add the current_day along with an empty places array to the existing array structure if one hasn't been previously provided. How can I do this?
data.data.trek.days[current_day].places.push({
"url": url,
"img_src": img_src,
"title": title,
"time_going_hour": time_going_hour,
"time_going_minutes": time_going_minutes,
"duration": "3600",
"id": id,
"type": type,
"city_id": city_id
});
data.data.trek.days[current_day].placeshas length?console.log(data.data.trek)and see if days exist as a member