Okay, so this is something i partially have working (ignoring case sensitivity) comparing the following:
arrayA = ["apples", "Oranges", "salt", "Cracked Black Pepper"];
arrayB = ["salt", "pepper", "orange"]
which works 'partially' with the following:
findAnyMatch(arrayA, arrayB): string[] {
let returnArray = [];
let conditionedArrayA = arrayA.map(i => i.toLowerCase().trim())
for (let i = 0; i < arrayB.length; i++) {
if (conditionedArrayA .includes(arrayB[i].toLowerCase().trim())) {
ret.push(arrayB[i].toLowerCase().trim());
}
}
return returnArray;
}
Which returns: "salt", "orange"
quite happily; the problem being that it can't see "pepper" in arrayA because it has "cracked black" in front of it.
How do i get it to search anywhere inside each string of the conditioned arrayA?
Thanks