Skip to content

Instantly share code, notes, and snippets.

@Lahirutech
Created February 6, 2023 16:18
Show Gist options
  • Save Lahirutech/b4b6087e1d8b1dc4f698801babab6f5f to your computer and use it in GitHub Desktop.
Save Lahirutech/b4b6087e1d8b1dc4f698801babab6f5f to your computer and use it in GitHub Desktop.
function searchObjectArray(players, searchString, keys) {
return players.filter(player => {
return keys.some(key => {
return getValueFromKey(player, key).toString().toLowerCase().includes(searchString);
});
});
}
function getValueFromKey(object, key) {
return key.split(".").reduce((o, i) => o[i], object);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment