Skip to content

Conversation

@ankit957173
Copy link

for index out of bound if index provided should be larger than array length and in require index should be smaller than array length

for index out of bound if index provided should be larger than array length and in require index should be smaller than array length
Copy link

@kanian kanian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's

if (_index > arr.length - 1) {
            return;
        }

Let's say arr.length = 6; If you say _index > arr.length, you will get the case where _index = 6, which is clearly out of bounds, but with ( _index > arr.length ) == false;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants