var str;
var displayedNum;
for (i in imgURLArray){
str = \"\" + \"\"+ (1+i) + \"\" + \" \
The reason is due to your loop:
for (i in imgURLArray){
This iterates over all the property names of imgURLArray
as strings. So you will need to use Number()
to convert i
to an integer:
str = "- " + ""+ (1+Number(i)) + "" + "
";