|
You left out the glorious sister project:
It is also important to know if a number is odd, so additionally I created this other package @samuelmarina/is-odd
Spoiler: It's not just function isOdd(x) { return !isEven(x); }
|
|
|
|
|
function isOdd(x) { return isEven(x-1); } ?
function isOdd(x) { return isEven(~x); } ?
|
|
|
|
|
Your sanity only wishes those were the case
Also that second one is clever.
|
|
|
|
|
PIEBALDconsult wrote: function isOdd(x) { return isEven(x-1); } The sad thing is that that wouldn't work when testing against '1' as that would be testing to see if 0 was even and their isEven does not have a test for 0.
|
|
|
|
|
I grew up with classmates named Odd and Even (which are not unusual boy's names around here). There was never any problem keeping them apart.
|
|
|
|
|
Oh. My. Word.
|
|
|
|
|
42 MEGABYTES OF JAVASCRIPT?!
Someone needs their head checked!
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Maybe they'll add a few icons later.
|
|
|
|
|
Brisingr Aerowing wrote: 42 MEGABYTES OF JAVASCRIPT?!
Meh. It'll get lost in the framework(s) downloaded with it.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
|
Don't waste my time, hahaha!
|
|
|
|
|
They have forgotten about negative numbers
|
|
|
|
|
And 0 . Is 0 even or odd? How can we know when that code is lacking the answer to this most important question?
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
doesn't it throw an exception?
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Well, if you troll, then you might just as well do it right, walking the walk way to the end.
|
|
|
|
|
..lead the way please..
..you will be lost first..
🤩🤩🤩🤩
|
|
|
|
|
That reminds me on that Simpsons episode. The boys hop into the caravan to steal back the lemon tree stolen by Shelbyvillians. After running through Shelbyville for basically ever, someone asks Homer, where he leads them. "I was following Flanders".
|
|
|
|
|
In all seriousness, it also tells if a written number is even or odd.
I've seen worse.
|
|
|
|
|
That just means the package is doing too much. Converting words to numbers should be separated out into its own package, since it's nothing to do with the purpose of the is-even package.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm sure this project is a gag! (and I'm snickering!)
Has anyone yet suggested porting this to some cloud-native database of the even numbers?
|
|
|
|
|
Feel free to suggest it[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
What? I am probably dumb, or inexperienced, or both, but I see no practical use for this.
Zaphod
|
|
|
|
|
What? I am probably dumb, or inexperienced, or both, but I see no practical use for this.
|
|
|
|
|
Thanks for sharing this… I was looking for a way to stripe my html tables!
|
|
|
|
|
That can be done better with a recursive function:
function IsEven(number) {
if (number === 1 return false;
elseif (number === 2) return true;
else return IsEven(number - 2);
}
Now it does all positive numbers
EDIT: because I get serious reactions on this code
The code above is how NOT to do it - it's satire.
modified 20-Aug-21 8:19am.
|
|
|
|