|
GitHub - samuelmarina/is-even[^]
Quote: This is a 100% serious project, and it is made to help the community.
A brief excerpt:
function isEven(number) {
if(number === 1) return false;
else if(number === 2) return true;
else if(number === 3) return false;
else if(number === 4) return true;
else if(number === 5) return false;
else if(number === 6) return true;
else if(number === 7) return false;
They're up to 1,000,001 now. Help them grow!
TTFN - Kent
|
|
|
|
|
I could while away the hours
Conferrin' with the flowers,
Consulting with the rain;
And my head I'd be a scratchin'
While my thoughts are busy hatchin'
If I only had a brain.
The less you need, the more you have.
Even a blind squirrel gets a nut...occasionally.
JaxCoder.com
|
|
|
|
|
Only works with base-10 ?
Surely it would be better written recursively.
modified 17-Aug-21 16:57pm.
|
|
|
|
|
I... what?! I thought you were joking for a second but there actually is a definition for even and odd in generic bases. In even bases it's the last-digit test - odd is odd, even is even; in odd bases it's a test of the sum of all digits - odd is odd, even is even. That makes complete sense; it's just not something I've ever considered
|
|
|
|
|
Ckuf me backwards with a shovel, it's the first time I hear this.
GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
PIEBALDconsult wrote: Only works with base-10 ?
You just need to add conversion functions and call them first.
function hexToDec(number) {
if (number === 1) return 1;
else if (number === 2) return 2;
else if (number === A) return 10;
else if (number === B) return 11;
}
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
|
|
|
|
|
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
|
|
|
|