I am trying to return the objects which has key of submittedDate. But if i am trying with find() It's returning only the first object. And for map it's returning undefined for object not having submittedDate key. Please find my code with data and also the result I want. thanks in advance.
const data = [
{
id: '1',
name: 'Tully Stark',
submittedData:'mmmmm'
},
{
id:'2',
name: 'Nalani Romanova',
},
{
id:'3',
name: 'Nalani Romanova',
submittedData:'mmmmm'
}
]
const submitDate = data.find(item => item.submittedData)
console.log(submitDate)
data to return
const returnData = [
{
id: '1',
name: 'Tully Stark',
submittedData:'mmmmm'
},
{
id:'3',
name: 'Nalani Romanova',
submittedData:'mmmmm'
}
]
filterinstead.