I have an array named x like below.
x = [
{ id: 1, content: 'abc' },
{ id: 2, content: 'cde' },
{ id: 3, content: 'xyz' }
]
I have another array y like this.
y = [1, 3]
I want to fetch all data from x by mapping the id of x to the values in y.
So my output will be like below.
[
{ content: 'abc' },
{ content: 'xyz' }
]
How can I achieve this in Javascript?
