nit: to understand this line, I have to go back up to the start of the function to see what deleteIdx was initialized to.  Personally, I think this would be cleaner if you did 

if (n === items.length)

instead.