I would like help solving this exercise.
I have this array of objects and I would like the elements with the property ‘inCard= true’ consecutive to all be within a single ‘card’.
interface elementType {
inCard: boolean;
description: string;
}
const elements: elementType[] = [
{
inCard: true,
description: "Should be inside a card 1.",
},
{
inCard: true,
description: "Should be inside a card 2.",
},
{
inCard: true,
description: "Should be inside a card 3.",
},
{
inCard: false,
description: "NOT IN 4",
},
{
inCard: true,
description: "Should be inside a card 5.",
},
{
inCard: false,
description: "NOT IN 6",
},
];
Thanks for the help
Based on the given array then, I would like the first 3 elements to be inside a single card, then a break where the 4^ element is printed outside the card, then again a card with the 5^ element and last, the 6^ element outside the card.
more or less I want:
<div className='card'>
element1
element2
element3
</div>
element4
<div className='card'> element5 </div>
element6