Reputation: 2837
I have the following array which has strings in it
const dict = ['original sound', 'الصوت الأصلي', 'оригинальный звук'];
Now I want to filter it based on the array using object filter
Object.filter = (obj, predicate) =>
Object.keys(obj)
.filter( key => predicate(obj[key]) )
.reduce( (res, key) => (res[key] = obj[key], res), {} );
let filtered = Object.filter(audio, audio =>
audio.audio.title !== dict
);
To be clear I don't want any music with the titles that match the dict array
Upvotes: 1
Views: 55
Reputation: 209
If I understand correctly, you want to filter an array of strings, based on another string array as dictionary, if so, try below
var filtered = ['a', 'b', 'c', 'd'].filter(
function(e) {
return this.indexOf(e) < 0;
},
['b', 'd']
);
becarefull of string.includes(anotherString) is NOT working on IE
Upvotes: 0