Javascript Remove Array Element While Iterating Through A Dictionary