more than 6 values?
can you tell where exactly it is breaking? console.log(newArray) does it consist of all the values?
and what does "does not work" mean?
Well, when I'm giving 6 or less values. It's working properly. And the time I'm entering more than 6 values, it's happening like the picture.
note that (left + right) / 2 may return a decimal value, so your algorithm doesn't work if the array has an odd length (it can't even find 42 in [42])
Обсуждают сегодня