3 ms·
Why 2? Greater than 0, sure.
by gumby 5y ago
Why 2? Greater than 0, sure.
- lostcolony 5y agoYeah...I have an email address I use a lot, "me@(domain)". It's perfectly valid, despite indexOf("@") == 2.
- zamadatix 5y agoThe index of the first character is 0 and an email must have a local part so that means the index of "@" has to be at least 1. My guess is OP also forgot the index of the first character is 0 instead of 1 resulting in 1+1=2 (that or they meant >=). Off by one errors are about half of working with arrays.
- zarzavat 5y agoThis is actually an uncommon example of an off-by-two error as they used strictly greater than 2. a@domain fail ab@domain fail abc@domain ok
- deleted 5y ago[deleted]
- mkdirp 5y agoHeh, I actually meant `>=`. But as others have pointed out, that still excludes 2 letter users. Really it should be `>= 0`.
- lostcolony 5y ago> 0 I would think, no? Can an email address be '@domain', no preface?