Looking to search a value in an array of array and returning index. Most of the answers are array of objects. So I am looking to search for eg 22 and get 2 as the index where the value was found
Here is the code pen https://codesandbox.io/s/lodash-playground-array-pzzhe
const arr = [["a","b"],["f","r"],["r",22,"t"]];
console.log("arr", arr);
You could take plain Javascript with Array#findIndex
with Array#includes
.
var array = [["a", "b"], ["f", "r"], ["r", 22, "t"]],
value = 22,
index = array.findIndex(a => a.includes(value));
console.log(index);