Ad
  • Custom User Avatar

    The Boolean condition statements contradict each other.

    input=null  
    
    input != null || input != []
    
    input != null     (false)
    
    input != []  (true) 
    
    When null is input, it will always return true
    

    When a null statement is passed as input, it is not equal to empty array and returns true. Since you have used an OR conditional, it will pass through because at least one of the conditions statements were true. It attempts to find the length of null but because it itsn't an array, it doesn't have a length and therefore returns an error.