1var peakIndexInMountainArray = function (arr) {2//lets assume we have peak it divides array in two parts3// first part is increasing order , second part is decreasing4// when we find the middle we'll compare arr[middle] > arr[middle+1], it means5//we can only find max in first part of arr (increasing part) else second part.6//there will be point where start === end that is our peak7let start = 0;8let end = arr.length - 1;9while (start < end) {10let mid = parseInt(start + (end - start) / 2);11if (arr[mid] > arr[mid + 1]) {12end = mid;13} else {14start = mid + 1;15}16}1718return start;19};