It probably doesn't change the semantics, but did you mean to do ++i instead of i++? More standard to use i++ in for loops. A for loop is fine as well, but using a forEach on the html array is also a possibility.