In my case, the search should go through the first [1]
elements of nested arrays.
I added a loop through the array elements from the answer, but I can't add the found arrays to the array.
function massivs() {
let array = [['a', 'mango', 'b','c'], ['d', 'applemango', 'e','f'],['k', 'mangoapple', 's','r']];
let comp = ['apple', 'mango'];
let ans = [];
for (let i = 0; i < array.length; i++) {
for (el of array[i]) {
if (comp.every(y => el.includes(y))) {
ans.push(el);
}
}
}
console.log(ans);
}
massivs();
[ 'applemango', 'mangoapple' ]
Expected Result [['d', 'applemango', 'e','f'],['k', 'mangoapple', 's','r']]