I'm following this great tutorial for adding a property (or not) to an object based on a condition.
For example:
{ id: 'some-id', ...(true && { optionalField: 'something'})}
But in my case I have an object which looks like this:
What I'd like to do is if 12-AM
property exists, don't overwrite it, add to its property which is a key called message
which is an array
And if it doesn't add a new time key i.e. 1230-AM
to April-9-2020
This is what I have now:
{
...dayInfoInChild,
[currentDate]: { /* April-9-2020 */
[timeOfDayAndHour]: { /* 12-AM */
message: textValueContainer, ['foo']
},
},
}
But alas it doesn't add it overwrites...
Any help would be appreciated.