
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Inside the Array.prototype.upperBound function you have access to the "this" keyword. You can access array elements, values, and methods. For example "this[0]", "this[1]", "this.length", "this.map()", etc.
The most efficient way to solve this problem is with binary search.
Choose the middle element and check if it's less than or equal to the goal value. If so, you can rule out the left side of the array.