This is actually a bit more simple than it seems. The key points are:

1. Decrement the iteration count when you splice out an element
2. Remember to test .length during the loop’s conditional test (contrary to normal best-practice).

POC: http://jsfiddle.net/moagrius/983N2/