I am having issues trying to filter an array of message objects. I do not want to include the objects with "_id" value "receiver" or "blockedUsers".
Array of message objects:
[
{"_id":"receiver"},
{"_id":"blockedUsers"},
{"_id": MjIzx3XA1mpcuzgDVZj","createdAt":1631349363111,"text":"Ok","user":{"name":"Nikki","_id":"M6fBsPludfYVjJXKYvwgxHRacYw1"}},
{"_id":" MjG3hFAgcNweJWh9SF7","createdAt":1631300277391,"text":"Again","user":{"name":"Chris","_id":"tFhmw5oQoPhk8nF2sx5rE5BFqw93"}
}
]
The following doesn't seem to work
this.state.messages.filter(msg => !msg._id.includes("receiver") || !msg._id.includes("blockedUsers")).
The original array is returned.
But if I use this
this.state.messages.filter(msg => msg._id.includes("receiver") || msg._id.includes("blockedUsers"))
it returns:
[{"_id":"receiver"},{"_id":"blockedUsers"}]
Can you please assist?