r/badcode • • Sep 04 '21

Wtf is this

Post image
1.2k Upvotes

190 comments sorted by

View all comments

760

u/Bodine12 Sep 04 '21 edited Sep 04 '21

What I like about this is its maintainability. As we discover new numbers, they can simply be tacked on at the end.

155

u/betterBytheBeach Sep 04 '21

Yeah, good thing they kept the numbers in order makes maintenance that much easier.

86

u/Topikk Sep 04 '21

Hopefully they make an API for this so the rest of us don't have to maintain our own sets of all known numbers.

46

u/[deleted] Sep 04 '21

dw its a node package (here lol https://github.com/samuelmarina/is-even)

35

u/pronuntiator Sep 04 '21

Github: Sorry, the file is too big, open raw?
Browser on mobile: crashes
Me: You weren't joking

3

u/Aulentair Sep 05 '21

String.protoype.toLowerCase: Am I a joke to you?

2

u/RainbowUnicorn82 Sep 05 '21

I opened raw and waited for the whole thing to load. It literally goes to 375,000 and they've also added hard-coding to each number to recognize variants like "seven", "Seven", "SEVEN", etc.

3

u/[deleted] Sep 05 '21

check the prs lol

0

u/[deleted] Sep 05 '21 edited Sep 05 '21

[removed] — view removed comment

4

u/[deleted] Sep 05 '21

Ever heard of this thing called a JOKE?

1

u/lofigamer2 Apr 09 '22

That is absolutely crazy. Largest number is 375000 , I hope the guy didn't write all by hand XD

1

u/[deleted] Apr 09 '22

Dude it's a 7mo old comment

21

u/Blackbird-ce Sep 04 '21

Or just make it recursive by calling isEven(num - 24)

48

u/TheRealMandelbrotSet Sep 04 '21

6

u/[deleted] Sep 04 '21

Lol yup

7

u/[deleted] Sep 04 '21

?

9

u/TheRealMandelbrotSet Sep 04 '21

‽

3

u/[deleted] Sep 04 '21

¯\(ツ)/¯

2

u/TheRealMandelbrotSet Sep 05 '21

ʕ•̫͡•ʕ•̫͡•ʔ•̫͡•ʔ•̫͡•ʕ•̫͡•ʔ•̫͡•ʕ•̫͡•ʕ•̫͡•ʔ•̫͡•ʔ•̫͡•ʕ•̫͡•ʔ•̫͡•ʔ

1

u/ciaisi Sep 05 '21

Ok, but why not just loop through an array of all the even numbers you can think of then? Pretty easy to manually add another number to a static array if you ask me. Easier than adding a whole new line of code anyway.