Implemented QuickSort in JavaScript with a random pivot