Skip to content

Instantly share code, notes, and snippets.

@buwilliams
Created July 27, 2018 16:36
Show Gist options
  • Save buwilliams/cc83d805687f05e817c7f0843561dce4 to your computer and use it in GitHub Desktop.
Save buwilliams/cc83d805687f05e817c7f0843561dce4 to your computer and use it in GitHub Desktop.
Search for Icons in JSON
var icons = {
"cog": {
"search": "cog settings"
},
"disk": {
"search": "disk save"
}
}
function search(icons, searchString) {
var foundIcons = _.filter(_.keys(icons), function(key) {
var search = icons[key].search;
return (search.indexOf(searchString) !== -1);
});
return foundIcons;
}
var results = search(icons, "cog");
console.log(results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment