I am currently working on data filtering and struggling to extract text values from the tags
property for comparison with the input array. How can I implement this in JavaScript?
let user_input =["Bananas", "Kiwi"]
const data= [
{
id: 18,
username: "james",
tags: [ { id: 1, text: "Bananas" }, { id: 2, text: "Mangos" }]
},
{
id: 17,
username: "anita",
tags: [ { id: 3, text: "Bananas" }, { id:4 , text: "Oranges" }, { id:5 , text: "Strawberries" } ]
},
{
id: 16,
username: "david",
tags: [ { id: 2, text: "Mangos" }]
},
{
id: 15,
username: "nicole",
tags: [ { id: 6, text: "Kiwi" }]
},
]
The expected output should be
[{id: 18 ...}, {id:17 ...}, {id:15 ...}]