---
id: 69b279bae0f20eda63163cf3
title: Step 9
challengeType: 1
dashedName: step-9
---

# --description--

Inside the loop, start comparing the current elements from each half so you can merge the smaller value first.

Add an `if` block that checks if the current element in `leftPart` is less than the current element in `rightPart`. 
# --hints--

The `if` condition should check if `leftPart[leftArrayIndex]` is less than `rightPart[rightArrayIndex]`.

```js
assert.match(
  __helpers.removeJSComments(mergeSort.toString()),
  /if\s*\(\s*leftPart\s*\[\s*leftArrayIndex\s*\]\s*<\s*rightPart\s*\[\s*rightArrayIndex\s*\]\s*\)\s*\{/
);
```

# --seed--

## --seed-contents--

```js
function mergeSort(array) {
  const middlePoint = Math.floor(array.length / 2);
  const leftPart = array.slice(0, middlePoint);
  const rightPart = array.slice(middlePoint);
  
  mergeSort(leftPart);
  mergeSort(rightPart);
  
  let leftArrayIndex = 0;
  let rightArrayIndex = 0;
  let sortedIndex = 0;
  
  while (leftArrayIndex < leftPart.length && rightArrayIndex < rightPart.length) {
--fcc-editable-region--
    
--fcc-editable-region--
  }
}
```
