Created
July 27, 2018 16:36
-
-
Save buwilliams/cc83d805687f05e817c7f0843561dce4 to your computer and use it in GitHub Desktop.
Search for Icons in JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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