That's one way to do it
-
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! :doh:
TTFN - Kent
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 :laugh: EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.
-
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 :laugh: EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.
-
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! :doh:
TTFN - Kent
I'm trying to guess what certain CPers would do if they were confronted with this person. JSOP - bullet in the guy's head to put both the guy and everyone else out of their misery. honey the codewitch - After she quit twitching, she'd write a parser to optimize the code. OriginalGriff - figures out how to turn it into a CCC clue Nagy - just wanders off, asking where the gin is. Me - I'd tell him to turn it all into a switch statement.
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
-
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! :doh:
TTFN - Kent
You know... It's 2021, and the IRONY flows freely in all things... I expected to see a macro (written in JavaScript), that writes the javascript file: for (x..) if x % 1 == 0 write "if (number == " + x +") return false;" else write "if (number == " + x +") return true;" == And to see him asking people to crowd source running that file, to help him out! == Next question... Where is his test harness... Or is he caught in an infinite loop?
-
I'm trying to guess what certain CPers would do if they were confronted with this person. JSOP - bullet in the guy's head to put both the guy and everyone else out of their misery. honey the codewitch - After she quit twitching, she'd write a parser to optimize the code. OriginalGriff - figures out how to turn it into a CCC clue Nagy - just wanders off, asking where the gin is. Me - I'd tell him to turn it all into a switch statement.
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
-
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! :doh:
TTFN - Kent
They've missed a whole set of entries for those that speak British style English. American: Thirty-Two Thousand One Hundred Twelve British: Thirty-Two Thousand One Hundred And Twelve I'd better get editing...
-
They've missed a whole set of entries for those that speak British style English. American: Thirty-Two Thousand One Hundred Twelve British: Thirty-Two Thousand One Hundred And Twelve I'd better get editing...
Someone's already beaten you to that suggestion: [Feature Request] Support for British English "and" · Issue #85 · samuelmarina/is-even · GitHub[^] :-D
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
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 :laugh: EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.
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.
-
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 ;P EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.
-
They've missed a whole set of entries for those that speak British style English. American: Thirty-Two Thousand One Hundred Twelve British: Thirty-Two Thousand One Hundred And Twelve I'd better get editing...
The AND denotes the decimal or fractional portion of the number. So Brits in the example above, Twelve whats?
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
-
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 ;P EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.
And now this line of code is used: IsEven (4.2); It'll bounce around 0 until the heat death of the universe.
-
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 ;P EDIT: because I get serious reactions on this code The code above is how NOT to do it - it's satire.
-
The AND denotes the decimal or fractional portion of the number. So Brits in the example above, Twelve whats?
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
Not in British English (or just "English", as it's known). :) "One hundred and twelve" ===
112
, not100.12
.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
function isOdd(x) { return isEven(x**-1**); } ? function isOdd(x) { return isEven(**~**x); } ?
-
The AND denotes the decimal or fractional portion of the number. So Brits in the example above, Twelve whats?
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
The British English convention is to put an 'and' between any hundreds and non-zero tens/units and 'point' to indicate the fraction part. Therefore 123,456.789 is... "One hundred and twenty three thousand, four hundred and fifty six point seven, eight, nine"
-
And
0
. Is0
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.
-
I'm trying to guess what certain CPers would do if they were confronted with this person. JSOP - bullet in the guy's head to put both the guy and everyone else out of their misery. honey the codewitch - After she quit twitching, she'd write a parser to optimize the code. OriginalGriff - figures out how to turn it into a CCC clue Nagy - just wanders off, asking where the gin is. Me - I'd tell him to turn it all into a switch statement.
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
Me: Have Security dress the guy in a hazmat suit, and escort him out of the building. I'd then cordon off the area and decontaminate everything he touched on his visit - in an autoclave, by choice. This level of stupidity leaves traces wherever it goes.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
-
Someone's already beaten you to that suggestion: [Feature Request] Support for British English "and" · Issue #85 · samuelmarina/is-even · GitHub[^] :-D
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Now the question is... Is the one with that request trolling him? Or does he really needs it for his usage?
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.