How to filter the data containing array inside the data?

Viewed 51
const arrayList = [{
  fNo: 343,
  origin: "Singapore",
  destination: "India",
  upType: ["Eco to PEco", "Eco to HClass"]
}, . {
  fNo: 363,
  origin: "Chennai",
  destination: "Singapore"
  upType: ["PEco to HClass"]
}]

const fiteredRulesData =
  arrayList.filter((data: any) => data.fNo.toString().includes(fNo.toString()))

&& ...similarly for other data like origin and deatination && how to do it for the upType array)

other is working but upType is not. Getting values fNo, origin and destination from the input but on selecting data getting upType as filterUpType = ["Eco to PEco"]

1 Answers
const filteredItems = arrayList.filter(item => item.upType && Array.isArray(item.upType) && item.upType.indexOf("Eco to PEco") !== -1)
Related