Javascript Loops Complete