<div id="dat"></div>
<script type="text/javascript">
var data = "";
var arr =[3343,454,6566,766,8778];
for (i = 0; i < arr.length; i++){
data += '<div id ="' + 'length' + i + '">' + num + '</div>';
};
var dat = document.getElementById('dat');
dat.innerHTML = data;
</script>
<div id="dat"></div>
<script type="text/javascript">
var arr =[3343,454,6566,766,8778];
document.getElementById('dat').innerHTML=arr.map((num,i)=>`<div id="length${i}">${num}</div>`).join('\n');
</script>