I have a list of n elements that I want to output in a group of 3. The size of the collection can vary a lot, but the output must be grouped in 3.
<ul>
<li>
<div>element 1</div>
<div>element 2</div>
<div>element 3</div>
</li>
<li>
<div>element 4</div>
<div>element 5</div>
<div>element 6</div>
</li>
<li>
<div>element 7</div>
<div>element 8</div>
</li>
</ul>
I would like to use a forEach and a if statement, but I cannot get the output to generate properly. Any suggestions?