How to create a binary search with recursion

I am attempting to write a “binary search” which I’ve never done before. The code below does not work when the value searched for is 6 or 2 and I want to know what I am doing wrong and how to remedy it. EDIT To explain what it is suppose to do (based on my understanding) a binary search requires that an array is already sorted, it then looks for the mid-point index of an array. For example, if an array had nine indexes (0-8)the the mid point would be index 4. The algorithm then determines if that mid point

How to get the last children in a deeply nested array with objects

So let’s say I have a deeply nested array and I want to get the deepest nested children and I’m unable to think of a good way to implement it basically as long as the children property exists, it needs to dive inside it and it not I want to test if the name matches my search Answer hasOwnProperty() may help you knowing if the property Children exist or not, and then, knowing if you need a recursive call or not For example :