I am creating a helper function to convert a Object of data into an array using javascript. Here is a sample of the data that I want to convert.
const DATA = {
{
title: 'Jun 23, 2021',
data: [
{
messageSentTime: '6:32 PM',
senderAvatar: 'okef8ia9fkil3drzxemy',
senderMessage: 'FsvaevseVefwe'
}
]
},
{
title: 'Jun 23, 2021',
data: [
{
messageSentTime: '6:32 PM',
senderAvatar: 'okef8ia9fkil3drzxemy',
senderMessage: 'FsvaevseVefwe'
}
]
},
}
Here is what I want to update the data to.
const DATA = [
{
title: 'Jun 23, 2021',
data: [
{
messageSentTime: '6:32 PM',
senderAvatar: 'okef8ia9fkil3drzxemy',
senderMessage: 'FsvaevseVefwe'
}
]
},
{
title: 'Jun 23, 2021',
data: [
{
messageSentTime: '6:32 PM',
senderAvatar: 'okef8ia9fkil3drzxemy',
senderMessage: 'FsvaevseVefwe'
}
]
},
]
Here is what I tried to convert the data.
Object.keys(dateOfConversation).map(i => dateOfConversation[i])
I am guessing I need to use the reduce method, and I do not know how to use it. Any help would be greatly appreciated.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment