<html>
<head>
  <meta charset="utf-8">
  <title>Mocha Tests</title>
  <link href="https://unpkg.com/mocha@5.2.0/mocha.css" rel="stylesheet" />
</head>
<body>
  <div id="mocha"></div>

  <script src="https://unpkg.com/chai/chai.js"></script>
  <script src="https://unpkg.com/mocha@5.2.0/mocha.js"></script>

  <div></div>
  

</body>
</html>
function quickSort(arr,length = arr.length-1,start=0){
  
  if(arr.length < 2) return arr // base case
  
 const pivot = arr[arr.length-1];
 const left  = [];
 const right = [];
  
  while(start < length){
    if(arr[start] < pivot) left.push(arr[start])
    else right.push(arr[start])
    start++
  }
  return [...quickSort(left),pivot,...quickSort(right)];
}

console.log(quickSort([4,9,2,6,8,10,3,1,7,5]))



mocha.setup('bdd');


var assert = chai.assert;

describe('QuickSort',()=>{
  
  it("sorted correctly",()=>{
   
    const ans = quickSort([4,9,2,6,8,10,3,1,7,5])
    assert.deepEqual(ans,[1,2,3,4,5,6,7,8,9,10]);
  })
  
})



mocha.run()

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.