I have an array that looks like this:
var arr = [["present",["John","Josh","Jay"]],["absent",["May","Mary","Mary Jane"]]];
var arr2 = [["J",["John","Josh","Jay"]],["M",["May","Mary","Mary Jane"]]];
My goal is to retrieve the data[0]
of the array containing the value "Mary"
.
In this case, I should get "absent"
.
Additionally, I want to find the index of the array in arr2 that includes the value "Josh"
.
Therefore, I would expect to get 0 from my second array.
If it's possible to utilize underscore js for this task, I'm open to using it.
I attempted to apply _.contains()
but encountered issues.
Furthermore, these arrays are being used in a knockout js context.