---
id: 69b279bae0f20eda63163cfa
title: Step 16
challengeType: 1
dashedName: step-16
---

# --description--

Copy the remaining left values into `array` by assigning `leftPart[leftArrayIndex]` to `array[sortedIndex]`.

# --hints--

The loop body should assign `leftPart[leftArrayIndex]` to `array[sortedIndex]`.

```js
assert.match(
  __helpers.removeJSComments(mergeSort.toString()),
  /while\s*\(\s*leftArrayIndex\s*<\s*leftPart\.length\s*\)\s*\{[\s\S]*array\s*\[\s*sortedIndex\s*\]\s*=\s*leftPart\s*\[\s*leftArrayIndex\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) {
    if (leftPart[leftArrayIndex] < rightPart[rightArrayIndex]) {
      array[sortedIndex] = leftPart[leftArrayIndex];
      leftArrayIndex += 1;
    } else {
      array[sortedIndex] = rightPart[rightArrayIndex];
      rightArrayIndex += 1;
    }
    sortedIndex += 1;
  }

  while (leftArrayIndex < leftPart.length) {
--fcc-editable-region--
    
--fcc-editable-region--
  }
}
```
