i am returning a structure of an object of folders and the contents of the json files contained in them. this is how it's looks like.
{
DailyTask: [ { title: 'Chores', body: 'Wash the roof and sweep the bed' } ],
monday: [{ title: 'madrid', body: 'Wash the roof and sweep the bed' } ],
}
i have a problem when a folder has more than two files, because i can't find a way to append to the array of either monday or DailyTask
i tried doing concat or push but they wouldn't work at first because the object property is undefined so i did the first assignment would be done via square brackets and subsequent ones will be done via push or unshift i.e x is the json file
if (sum[key] == undefined) {
sum[key] = x;
} else {
sum[key].unshift(x);
}
gives me this
{
DailyTask: [ { title: 'Chores', body: 'Wash the roof and sweep the bed' } ],
monday: [
[ [Object] ],
{ title: 'madrid', body: 'Wash the roof and sweep the bed' }
]
}
it shows as [[Object]], how do i make the actual contents of the object show.
{ title: 'Chores', body: 'Wash the roof and sweep the bed' }and{ title: 'madrid', body: 'Wash the roof and sweep the bed' }correct?