i think you can just "return undefined" (or just simply "return") here but you definitely should change the comment.  

The comment confused me as did the i = -1.  The intent is that you need to start displaying the items from x and you need to skip over 0 ... (x - 1) before you start adding to what is displayed to the user. so setting i = -1 skips the block that starts on 381

Another thing that is really confusing about this block is the use of 'resultDisplayed'.  This is a carry over from the previous implementation which truly was the list of results that were displayed.  In this case it is the number of items we've iterated over.  I'm not sure of the name to use.  maybe itemNumber, i don't know but whatever it is there needs to be a big comment around how it's used as this is some tricky code to decipher.