Create Custom grid css depending on Array Length <p>I have array with data <code>[1,2,3,4,5,6,7]</code> and I want to show 2 items on 1 line</p> <pre><code>&lt;div class=row&gt; &lt;div&gt;data1&lt;/div&gt; &lt;div&gt;data2&lt;/div&gt; &lt;/div&gt; &lt;div class=row&gt; &lt;div&gt;data3&lt;/div&gt; ... </code></pre> <p>So I want do it with JS. As I understand I need smth like <code>[[1,2],[3,4],[5,6],[7]]</code>, but cant understand how to make it. It'll be great if someone did it before and can help me.</p>