DEV Community

Discussion on: Binary Search

Collapse
 
hajarnasr profile image
Hajar | هاجر

Thank you so much for your feedback @stefnotch . 😀
I fixed the no-parameters issue but am curious, why do you think that parseInt isn't needed here? Aren't we using it to avoid having fractions in the middle index? 🤔

Collapse
 
stefnotch profile image
stefnotch

I see, I missed that detail!

Although, parseInt is not designed for that. It's purpose is to turn a string (text) into a number. If the intention is to chop off the fractional part, then Math.floor is the standard function to use.
e.g. start + Math.floor((end - start) / 2)