Must I loop to search results for a specific value?
- by tag
I have a table in the database:
name Opinion
Tim Tim has an opinion
John other random text
Dan Dan's random text
Al Al says something else
I call this data and get it back in
getRecords.lastResult
To access John's opinion, I could use:
getRecords.lastResult[1].opinion
But that's only because I know that John is the second record (record 1), but this may change. So the right way is to search through the results to first find the record index for John, then access his opinion.
My guess is I need some sort of a loop? Is there an easier way to search for John directly without a loop?