I was confused when I read the second part of the test. The variable name was index2, and "30 should be inserted at index 2". But then I looked a few lines up, and saw that index's number "should be inserted at index 3". I had thought that the '2' at the end of 'index2' meant something it didn't. This renaming prevents that confusion. This change highlights the repetition in this test. It is possible that a good next step would be to refactor the testing of these two numbers into an each loop. Or perhaps that would make the test unnecessarily complicated. I am not confident enough to make that call, so I'll leave it as it is.
sortedIndex should specify that it returns the lowest index at which an item may be inserted to maintain sorted order, rather than any index which satisfies this property, in order to provide easier use maintaining a sorted list of unique elements. For example, with the previous specification, the following behavior is possible: _.sortedIndex([10, 20, 30, 40], 30) => 3 To accommodate this behavior users would have to check both array[si] and array[si-1] (when si > 0) before inserting to ensure uniqueness, or to examine the underscore.js implementation and rely on the implementation not changing. Note: This specification change does not require any changes to the code. Signed-off-by: Kevin Locke <firstname.lastname@example.org>