jQuery.inArray()

Search for a specified value within an array and return its index (or -1 if not found).

.map()

Pass each element in the current matched set through a function, producing a new jQuery object containing the return values.

.prevAll()

Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector, in the reverse document order.