I am trying to modify the values of an object by using .fromEntries().
As you can see in the picture below, I am literally returning a modified Array of hours, but after the function ends, it returns the complete Array, instead of the updated one.
Thank you for any ideas in advance!
let filteredDates = Object.fromEntries(Object.entries(slots).filter(([slot, value]) => {
let result = datesArray.some(filterdates => {
return filterdates.some(filter => slot === filter)
})
let currentDay = slot === day ? value.filter(time => time >= currentHour) : null
result = currentDay ? currentDay : result ? value : result
console.log("result",result)
return result
}))
console.log("filteredDates",filteredDates)

I think the closest solution to your current approach is to
mapfirst, returningnullfor the entries you want to delete, and thenfilterout thenullentries to preventObject.fromEntriesfrom throwing. In code:If you want to do it in one pass, you could skip
Object.fromEntriesandreducethe entries in to an object yourself: