Why can't my code pass the test?

Tell us what’s happening:

This part doesn passed " quickSort should return an array that is unchanged except for order." when i tested the code on the chrome console. it works exactly as expect, I am comfusing.

Your code so far

function quickSort(array) {
  if(array.length<2) return array;
  const basic = array[0],left=[],right=[];
  for(let i=1;i<array.length;i++){
      const iv = array[i];
      iv > basic && right.push(iv);
      iv < basic && left.push(iv);

  return quickSort(left).concat(basic,quickSort(right));

// test array:
// [1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36.

Challenge: Implement Quick Sort

Link to the challenge:

hey @mitaosi

so this is the test that does not pass - quickSort should return an array that is unchanged except for order. so it looks like passing left=[],right=[] back into your function are causing it to fail as you should be returning the original array.

and when iv == basic?
it may happen that you are losing elements

Hey @mitaosi,

Your solution is giving only 13 items in the result, when the test array has 17 numbers. As ieahleen mentioned, the solution is removing numbers that are equal to basic.
Also, it is removing all duplicate numbers.