How do you perform a binary search in a given array in TypeScript
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
TypeScript
🤖 Code Explanation
This code is written in TypeScript and is a function that performs a binary search on an array of numbers. The function takes two parameters, an array of numbers and a number to search for. The function returns the index of the number if it is found in the array, or -1 if it is not found.
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
More problems solved in TypeScript
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968381.png)