-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
changeChange an existing featureChange an existing feature
Description
Currently, if using a return within a while loop, nothing happens. For example, the follow doesn't work when returning the pivot value directly:
function search(numbers, value) {
left = 0
right = numbers.length() - 1
while (left <= right) {
pivot = left + ((right - left) / 2).round()
if (numbers[pivot] == target) {
return pivot // this should exit the loop and return the value
}
if (value < numbers[pivot]) {
right = pivot - 1
} else {
left = pivot + 1
}
}
return -1
}
print(search([1, 2, 3], 2)) // should return 1Metadata
Metadata
Assignees
Labels
changeChange an existing featureChange an existing feature