Ad
  • Default User Avatar

    Exactly as AcesOfGlory said: In your solution is no check for null.

    Btw:
    With 3 ` at the beginning and at the end of a code block, you can give it a better visualisation.

    example
    if (a < b) ...
    
  • Custom User Avatar

    Change the order of your null check. Since code executes from left to right, the null value will be checked if it has a length less than 2 then it will check if it is a null. However, you want to check if it is a null first since a null value can't have a length and therefore fails the first bit of the null check.

    Change it to if (numbers == null || numbers.length < 2)