I count with the following example array
let animals = ['dog', 'cat', 'egypt cat', 'fish', 'golden fish']
the basic idea is get to the following result removing the elements which are included on the other strings
['dog', 'egypt cat', 'golden fish']
My approach was detect which are included iterating twice on the array and comparing the values
let arr2 = []
arr.forEach((el, i) => {
arr.forEach((sub_el, z) => {
if (i != z && sub_el.includes(el)) {
arr2.push(el)
}
})
})
then filter the array with those matched values. Anyone has a simplest solution?