<div>
<div>12</div>
<div>34</div>
<div>56</div>
<div>78</div>
<div>9</div>
</div>
var arr = [1,2,3,4,5,6,7,8,9],
count = arr.length,
str = '';
for (var i = 0; i < count; i++) {
str += '' + arr[i];
if ((i+1) % 2 === 0 || (i+1) === count) {
$('#block').append('<div>' + str + '</div>');
str = '';
}
}
while (data.length) {
target.insertAdjacentHTML('beforeend', `<div>${data.splice(0, 2).join('')}</div>`)
}
https://jsfiddle.net/fpoLzf98/