Skip to content
Discussion options

You must be logged in to vote

This is possible in some edge cases:

  1. You provide a count parameter of 0
  2. You provide a count parameter of less than 0 (the value will get defaulted to 0)
    } else if (count < 0) {
    count = 0;
    }
  3. You provide an array parameter an empty array
    } else if (count > array.length) {
    count = array.length;
    } else if (count < 0) {

So in the case, you stated this will not happen, since the count parameter will default to a random value between 1 and the array length

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hazem-alabiad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants