Javascript/lodash/React(native) Fix my Filterfunction
Budget: €8 – €30 EUR
Im trying to filter my searchObject by using a keyword.
const searchObject = [{"id":"9508","t":"Saal"},{"id":"9507","t":"Ballsaal"},{"id":"9506","t":"Apfelwein"},{"id":"9505","t":"Holzapfel"},{"id":"9504","t":"Ball"},{"id":"9503","t":"Saaltreiben"}];
const handleSearch = keyword => {
if(term) {
var results= _.filter(searchObject,function(item){ return item.t.indexOf(keyword.toLowerCase()) >= 0 });
console.log(results);
} else {
console.log(searchObject);
}
};
The Original-Object stores 10.000 Items. This Object in this project is just an example.
I use my function for the keyword "saal" or "Saal". The function filters the Object and returns currently "Ballsaal" and "Saaltreiben" but not "Saal"... it should return "Saal", "Ballsaal" and "Saaltreiben".
const searchObject = [{"id":"9508","t":"Saal"},{"id":"9507","t":"Ballsaal"},{"id":"9506","t":"Apfelwein"},{"id":"9505","t":"Holzapfel"},{"id":"9504","t":"Ball"},{"id":"9503","t":"Saaltreiben"}];
const handleSearch = keyword => {
if(term) {
var results= _.filter(searchObject,function(item){ return item.t.indexOf(keyword.toLowerCase()) >= 0 });
console.log(results);
} else {
console.log(searchObject);
}
};
The Original-Object stores 10.000 Items. This Object in this project is just an example.
I use my function for the keyword "saal" or "Saal". The function filters the Object and returns currently "Ballsaal" and "Saaltreiben" but not "Saal"... it should return "Saal", "Ballsaal" and "Saaltreiben".