I have two arrays:
const Array1 = [
{id:1, sold: 69, productName: 'Epic' image: 'someimage.svg' } ,
{id:2, sold: 121, productName: 'Legend' image: 'someimage.svg' } ,
{id:3, sold: 368, productName: 'Top' image: 'someimage.svg' }
]
const Array2 = [
{ productBrand: 'Chiquita' , productName: 'Epic' , productCategory:'Banana' } ,
{ productBrand: 'Famoozo' , productName: 'Legend' , productCategory: 'Mango' } ,
{ productBrand: 'PinkLady' , productName: 'Top' , productCategory: 'Apple' }
]
And i want to display data in my JSX from both of them. I gave it a try with Array.map in map , but that is not the solution that i am after.
JSX
...
return (
<>
{
Array1.map((dataFromFirstArray) =>
Array2.map((dataFromSecondArray) => (
<div>
<img src={dataFromFirstArray.img} />
<p> {dataFromFirstArray.sold} sales </p>
<p> {dataFromSecondArray.productBrand} </p>
<p> {dataFromSecondArray.productName} </p>
<p> {dataFromSecondArray.productCategory} </p>
</div>
)
}
</>
)
UPDATE
How can i combine the array's into one if productName is the same in both of them. At the end of the day i want to use all the data but coming from one array.
