---
id: 6996cb5869acf58de751ae81
title: Step 10
challengeType: 1
dashedName: step-10
---

# --description--

Recall that the function takes an array called `searchList` and the `value` you're looking for.

Now, call the function with `binarySearch([1, 2, 3, 4, 5], 3)` and `binarySearch([1, 2, 3, 4, 5, 9], 4)` and log both statements to the console.

# --hints--

You should call the function with `binarySearch([1, 2, 3, 4, 5], 3)` 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*2\s*,\s*3\s*,\s*4\s*,\s*5\s*\]\s*,\s*3\s*\)\s*\)/
);
```

You should call the function with `binarySearch([1, 2, 3, 4, 5, 9], 4)` 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*2\s*,\s*3\s*,\s*4\s*,\s*5\s*,\s*9\s*\]\s*,\s*4\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;
    }
    break;
  }
  return [];
}

--fcc-editable-region--  

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