4 ms·
I see an error. "hadc0ffee" is neither hexadecimal nor matches that regex. Am I missing something?
by beastman82 2y ago
I see an error. "hadc0ffee" is neither hexadecimal nor matches that regex. Am I missing something?
- simonkagedal 2y agoI was also wondering what they were trying to say with that.
- huffstler 2y agoI believe they're showing an example of where people would use (incorrect) regex patterns to validate. That's the whole thrust of the previous paragraph. `hadc0ffee` is not valid hex, but the function says it is due to, I presume, an incorrect regex pattern. I'm not familiar enough with regex to know why it's wrong though. Edit: I was curious, so I looked through the linked docs for regex. They have the exact same pattern for checking hex in there as they do in this one. I guess it was just an error after all?
- jethkl 2y agoYou are missing the joke. The correct line would read: isHexadecimal("HADC0FFEE"); // false
- graypegg 2y agoso, I thought there was some esoteric weirdness in the spec'd Javascript regex engine that made HADC0FFEE somehow match /^[0-9A-F]+$/i. Then the joke kinda makes sense right? I do need coffee to work with JS most of the time haha But I do get false, running it in chrome dev tools. When they're talking about writing documentation for tricky subjects, this misses a bit. I have no clue what the joke is, other than, if you haven't had coffee, you might think this evaluates to true?
- bee_rider 2y agoI think that is the jokey, yeah. Also a tiny bit of a pun maybe, it looks sort of like a status test of some sort: did you have coffee?