---
id: 6996d0a2c2ac55041145a13f
title: Step 14
challengeType: 1
dashedName: step-14
---

# --description--

Did you notice the second function call now has the values `3, 5, 4` in the list? That indicates the binary search is working as intended.

This is how it happened: The algorithm first checked `3` as the middle of the initial list. Since `4` is greater than `3`, the search shifted to the right half. It then examined `5` as the new middle. Because `4` is less than `5`, the search moved to the left, ultimately identifying `4` as the middle of the final range.

To test the function again, call it with `[1, 3, 5, 9, 14, 22], 10` and log it to the console. This is a situation in which the value will not be found.

# --hints--

You should call the function with `binarySearch([1, 3, 5, 9, 14, 22], 10)` and log it to the console.

```js
assert.match(
  __helpers.removeJSComments(code),
  /console\s*\.\s*log\s*\(\s*binarySearch\s*\(\s*\[\s*1\s*,\s*3\s*,\s*5\s*,\s*9\s*,\s*14\s*,\s*22\s*\]\s*,\s*10\s*\)\s*\)/
);
```

# --seed--

## --seed-contents--

```js
function binarySearch(searchList, value) {
  let pathToTarget = [];
  let low = 0;
  let high = searchList.length - 1;
  while (low <= high) {
    let mid = Math.floor((low + high) / 2);
    let valueAtMiddle = searchList[mid];
    pathToTarget.push(valueAtMiddle);

    if (value === valueAtMiddle) {
      return pathToTarget;
    } else if (value > valueAtMiddle) {
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  return [];
}

console.log(binarySearch([1, 2, 3, 4, 5], 3));
console.log(binarySearch([1, 2, 3, 4, 5, 9], 4));
--fcc-editable-region--

--fcc-editable-region--
```
