var text = [] for (let i = 0; i < countP; i++) { if (i < 5) { text[i] = str[i].innerHTML result[i].push(text[i]); } }