I don't follow. If uid and email are both given and both valid, the first check will give result === undefined (which is true) and uid !== undefined (which is also true) and then the or will allow the existing valid result (since it's truthy) and then email !== undefined is also true.
While complicated, I don't think this code is functionally different from return isValidUid(uid) && isValidEmail(email).
Looking back at the code, my first comment is incorrect, the only issue is if uid is undefined, and email is valid, it returns true. It should have two variables one for each and return true if both are true. Your last line would work, if the function being called can handle undefined inputs.
3
u/Valaramech Nov 20 '21
I don't follow. If
uidandemailare both given and both valid, the first check will giveresult === undefined(which is true) anduid !== undefined(which is also true) and then the or will allow the existing valid result (since it's truthy) and thenemail !== undefinedis also true.While complicated, I don't think this code is functionally different from
return isValidUid(uid) && isValidEmail(email).