I'm not a big fan of for loops. I would prefer a _.reduce here with an object that has an errorIds property and successIds property.