I have an array like this:
var = [
{
"a": "value",
"b": "value2"
},
{
"a": "value3",
"b": "value4"
}
...
]
I need to find if any of the subarrays contain a certain value.
I tried
var.flat().includes("value")
but that always returned false for some reason and .flat()
didn't even flatten the array.
I also tried
var.includes("value")
without the .flat()
but that would only return if the top level includes it.
I could do
var = [
"a": [
"value",
"value3"
...
],
"b": [
"value2",
"value4"
...
]
]
but I'd rather not since that'd require me to rewrite some code I already wrote.
question from:https://stackoverflow.com/questions/65516922/does-subarray-contain-a-certain-value