Let's say I have the following arrays:
var array_full = ['table', 'sleeping', 'data'];
var array_part = ['sleep', 'able'];
Now, I want to filter out items from the array with full strings (array_full
) if they contain items from the array with partial strings (array_part
).
I can do it like this:
var rez = [];
for (p in array_part) {
array_full.filter(function(f) { if (f.indexOf(array_part[p]) > -1) {rez.push(f)} } )
}
But I'm sure there is a better way, isn't it?
EDIT: Thanks to all!