I have two arrays and I am trying to display only the data that matches with the first array.
For example:
The first array looks like this:
["1", "2" , "3"]
The second array is as follows:
[{"name": "xyz", "id": "1"},{"name":"abc", "id": "3"}, ,{"name":"def", "id": "4"}]
The desired result would be:
[{"name": "xyz", "id": "1"},{"name":"abc", "id": "3"}}
I attempted the following code but it's returning an empty Array:
console.log(this.secondArr.filter(d => d.id === firstArr));