I would like to know how to get/fetch the object in nested array using javascript.
var value = "SGD"
var obj=[{
country: singapore,
ccy: ["EUR","SGD"]
amount: "1000"
},{
country: thailand,
ccy: ["THB"]
amount: "1000"
}]
function getData(){
return obj.filter((e)=>{
return e.ccy == value; // fetch array object if it matches the value
}
}
var result = getData();
console.log(result);
e.ccy.includes(value)should workfetch array object if it matches the value