This Stack Overflow question[
^] presents a very similar case to yours. See the first answer there -- concatenating string in a loop is not a good idea. It's better to keep an array, push all string parts into that array, and use
.join
after the loop to concatenate it all together.