<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
<span>6</span>
<script>
var arr = [[]], i = 0;
document.querySelectorAll('span').forEach(el=>el.onclick=e=>{
if(arr[i].length == 3) {
arr.push([]);
i++;
}
arr[i].push(el.textContent);
console.log(arr);
});
</script>