Can anyone help me with this code snippet? I'm trying to check if an element in the array starts with the letter Ա/ա, and then print it out in a paragraph. However, I'm having trouble making each word start on a new line.
for (var i = 0; i < aremove.length; i++) {
aremove = [...new Set(aremove)].sort()
if (/^[Աա]/.test(aremove[i])) {
var word = document.createTextNode(aremove[i])
document.getElementById("p").appendChild(word)
}
}
I've tried adding +"<br>"
, but it's not breaking the line, instead just adding <br>
to words. When I try using .join("<br>")
, I get errors like "TypeError: aremove[i].join is not a function" or "word.join is not a function". Any suggestions?