Binary Search loop

I have to do a binary search for a names directory in typescript, if the name is in the array the code works properly but if the name it’s not in the array it became in an infinite loop. Can somebody …