[javascript] Looping through array and removing items, without breaking for loop