I am working in React. I am trying to find out a solution to a mapping problem. While mapping an object or array in javascript, we know it delivers one item of the array/ object in per iteration. For Example:
Consider an array of object like:
const items = [
{
id: 1,
color: "red"
},
{
id: 2,
color: "blue"
},
{
id: 3,
color: "yellow"
},
{
id: 4,
color: "black"
}
];
Now,
items.map((item, i) => <p key={i}>{item.color}</p>)
This will show an output like :
red
blue
yellow
black
Now what if I want to bring multiple items in per iteration. For Example:
red blue
yellow black
How to do it ? Thanks in advance. Please feel free to use this codesandbox example:
https://codesandbox.io/s/musing-cloud-gnnye?file=/src/App.js:100-339