|
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.
|
|
|
|
|
Points for being clever.
Sadly, someone would still use it...
|
|
|
|
|
If someone really uses it, he or she deserves it 
|
|
|
|
|
Sometimes the best thing you can do is let others hang themselves.
Figuratively speaking.
|
|
|
|
|
No...only positive integers. Since this is JS, some jerk could pass a float in and get your recursive function to march off the negative end of the numbers.
|
|
|
|
|
Hmmm, you are right.
The the improved improved version.
function IsEven(number) {
if (number === 1) return false;
else if (number ===2) return true;
else if (number > 2) return IsEven(number - 2);
else return IsEven(number + 2)
}
Now it does negatives too
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.
|
|
|
|
|
And now this line of code is used:
IsEven (4.2);
It'll bounce around 0 until the heat death of the universe.
|
|
|
|
|
You are taking this code seriously?
|
|
|
|
|
..yes..is there anything else i should be serious about?..
🤪🤪🤪🤪
|
|
|
|
|
Why are all the 'else's there? Do they improve code generation?
|
|
|
|
|
No, they worsen it 
|
|
|
|
|
With big number (I mean really big numbers), you will run into a StackOverflowException.
What about "tail recursion"?
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
|