I\'ve got this code that checks for the empty or null string. It\'s working in testing.
eitherStringEmpty= (email, password) ->
emailEmpty = not email? or
It isn't entirely equivalent, but email?.length
will only be truthy if email
is non-null and has a non-zero .length
property. If you not
this value the result should behave as you want for both strings and arrays.
If email
is null
or doesn't have a .length
, then email?.length
will evaluate to null
, which is falsey. If it does have a .length
then this value will evaluate to its length, which will be falsey if it's empty.
Your function could be implemented as:
eitherStringEmpty = (email, password) ->
not (email?.length and password?.length)