Assuming that I have this multiple data and I need to filter set of elements. How could I only filter the data with only message
and createdAt
will produce:
var getMessage = [
0: {
status: 'SENT',
type: 'text',
createdAt: "2021-07-07T08:11:51.686Z",
web: {
message: {
text: "Get Started"
}
}
},
1: {
status: 'SENT',
type: 'text',
createdAt: "2021-07-07T08:11:53.547Z",
web: {
message: {
text: "Etrt"
}
}
},
2: {
status: 'SENT',
type: 'text',
createdAt: "2021-07-07T08:12:07.785Z",
web: {
message: {
text: "No answer found."
}
}
}
];
const findKeywords = "O"
const messageData = getMessage.map(x => x);
const findMessage = messageData.filter(x => x.web.message.text.toLowerCase().includes(findKeywords.toLowerCase()));
console.log(findMessage);
How could I only filter the data with only message
and createdAt
will produce:
[
createdAt: "2021-07-07",
text: "No answer found."
]