使用下面的数组,我需要按字母进行搜索,如果它找到了元素,它应该返回一个数组
例子const data= [[
"car",
"plane",
"boat"
],
[
"cartago",
"barcelona",
"los angeles"
],
[
"headphone",
"phone",
"camera",
]
]
if match "ca"必须返回
[car, cartago, camera]
if match "ne"必须返回
[plane, headphone, phone]
平放数组并检查子字符串是否包含在每个元素
const data= [[ "car", "plane", "boat" ], [ "cartago", "barcelona", "los angeles" ], [ "headphone", "phone", "camera", ]]
let a = data.flat().filter(v => v.includes('ca'))
console.log(a)
let b = data.flat().filter(v => v.includes('ne'))
console.log(b)