I have two arrays of an object X and y, form x value array ["N","Y"], I need to filter the y array options value, based on that I need to return the y array, I had tried with this:
const x = [{"application":"Collect","attr":[{"name":"document","value":["N","Y"],"disabled":true}, {"name":"video","value":["Y"],"disabled":false}]}]
const y = [{"name":"document","options":[{"name":"Yes","value":"Y"},{"name":"No","value":"N"},{"name":"view", value:"view"}]}]
const iArr = x[0].attr.map(m => {
m.value.map(o => {
y.map(yl => {
yl.options.filter(s => {
if (o === s.value) {
console.log(s)
}
})
})
})
})
console.log(iArr)
my output should be
const result = [{"name":"document","options":[{"name":"Yes","value":"Y"},{"name":"No","value":"N"}]}]