Sobes.tech
Junior — Senior

Implementation of binary search in an array

livecode

Task condition

Create a function that implements binary search. The function takes a sorted array of unique integers and a target value, returning the index of the found element or -1 if the element is not present.

function binSearch(arr, target) {
  // code
}

/* test 1— */
/* test 2— */

// const arr = ...;
// const result = binSearch(arr, ?);
// console.log(result);