so I have a multidimensional array. I want to get the key of one of the sub arrays, given a value.
var MyArr = [];
MyArr[0] = ['cat','black',5]
MyArr[1] = ['dog','red',7]
MyArr[2] = ['pig','blue',4]
what I want to be able to do is use a value say 'blue' and have it return the key of 2 so that I could take that 2 and do something like MyArr[2][0] to get 'pig'
I couldn't quite get indexof to work correctly.
any thoughts?
Also has to be pure JS cannot use JQuery
Math.floor( MyArr.flat().findIndex((val) => val === "blue") / MyArr.length );