amejiarosario/dsa.js-data-structures-algorithms-javascript

What if value in array is '-1'?

ofca opened this issue · 2 comments

ofca commented

I mean, what if array is something like:

const arr = [3, 4, -1, 3]

then this:

searchByIndex(arr, 2) will return -1

https://github.com/amejiarosario/dsa.js/blob/bb003f18651670dfd223452f8693b7b67f0f3b4d/src/data-structures/arrays/array.js#L48

That's a good point. I'll make a fix for it

Fixed with 2b94d37. It will return undefined so -1 can also be in the array