Skip to content

Instantly share code, notes, and snippets.

@Verthon
Created January 7, 2020 09:34
Show Gist options
  • Save Verthon/5a31373e454c9cda7d5031e547522688 to your computer and use it in GitHub Desktop.
Save Verthon/5a31373e454c9cda7d5031e547522688 to your computer and use it in GitHub Desktop.
Search children
const arr = [
{
"name": "Thea Sidiropoulos",
"daycareComment": null,
"parentComment": null,
"id": "86",
"away": null,
"checkin": [],
"additionalDay": false,
"remarks": "",
"awayClass": "",
"reason": "",
"addtionalClass": "",
"disableToggle": false,
"disabled": false,
"checkout": "Nicht anwesend",
"class": "notcheckin"
}
]
const ev = "Thea";
const search = (arr, ev) => {
const val = ev;
if (val && val.trim() != '') {
let children = arr.filter((item) => {
let name = item.name;
let search = (name.toLowerCase().indexOf(val.toLowerCase()) > -1);
console.log(search)
if (search) {
return item;
}
})
return children;
} else {
return children;
}
}
console.log(search(arr, ev))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment