text: /**
   * Given a sorted array, find the index of the element with the given value.
   * Time complexity should be O(logN)
   *
   * @param {Array} array
   * @param {Number} value
   * @return {Number}
   *
   * @example
   * For ([1, 2, 3], 1) should return 0
   * For ([1, 2, 3], 2) should return 1
   *
   */
  function findIndex(array, value) {
    let startIndex = 0;
    let endIndex = array.length - 1;
    let middleValue;
    let midIndex;
  
    while (startIndex <= endIndex) {
      midIndex = Math.floor((startIndex + endIndex) / 2);
      middleValue = array[midIndex];
      if (middleValue === value) {
        break;
      } else if (middleValue > value) {
        endIndex = midIndex - 1;
      } else if (middleValue < value) {
        startIndex = midIndex + 1;
      }
    }
  
    return midIndex;
  }
  
  module.exports = findIndex;
  