I've seen this question and this one but none of the answers seem to work for me.
The idea is to figure out what is inside colors1 and colors2, and retain only matching colors into another array: colorsPicked.
const colors1 = ["red", "blue"];
const colors2 = ["red", "yellow"];
const elements = ["red", "blue", "green", "yellow"];
const colorsPicked = elements.filter(el => colors1.concat(colors2).includes(el));
console.log(colorsPicked);
In the example above, colorsPicked contains: red, blue, yellow.
What I need to get as a result is only the colors that match between colors1 and colors2. That is to say, colorsPicked should return: red
if colors1 contains red, blue, yellow and color2 contains red, blue, black then colorsPicked should return: red, blue
How does one do this?