Say I have an array of objects similar to
[ {name:"value1", action:"U"}, {name:"text2", action:"d"} ]
with many more entries.
I want to look up a value in this, but with a snafu, Say I want to see if any of the words in the list is in the string “I want to look up value1” and return that index number. How might I approach this? This would be running in Node.JS if that matters.
As epascarello noted, just doing a simple for loop wrapped up in a function to get that index should do what you are looking for.
If you are looking for other ways to manipulate data, you may want to take a look at underscore.
EDIT: I looked at your initial question a bit incorrectly, also took note of @pimvdb escaping recommendation. This is probably more of what you want.