[Solved] Creating objects by splitting an object whose attributes are arrays [closed]


Using flatMap you can ungroup the elements in an array..

const fruit="apple"

const array=[ 
  { names:['something1', 'something2'],
    fruit: fruit,
    features:['feature1','feature2']
  }
]

array.flatMap(({names,fruit,features}) => {
  names.flatMap(name => {
    features.flatMap(feature => {
      console.log(({name,fruit,feature}));
    })
  })
})

5

solved Creating objects by splitting an object whose attributes are arrays [closed]