function binarySearchIterative(array, search) {
  let start = 0;
  let end = array.length - 1;
  const half = () => start + parseInt((end - start) / 2, 10);

  while (start <= end) {
    const currentIndex = half();
    const current = array[currentIndex];

    if (current === search) return currentIndex;

    if (search > current) {
      start = currentIndex + 1;
    } else if (search < current) {
      end = currentIndex - 1;
    }
  }

  return -1;
}
Iterative Binary Search

@return index of the found element or -1 if not found
@param {array} array collection of sorted elements
@param {string|number} search value to search for