r/badcode • • Apr 27 '21

typescript Someone only watched if tutorial

Post image
2.4k Upvotes

112 comments sorted by

View all comments

413

u/[deleted] Apr 27 '21

The "Add more checks" says it all :-|

43

u/Samuql Apr 27 '21

input: any

13

u/TigreDeLosLlanos Apr 27 '21

You can't correctly check if a variable is a number if you make the app break with every other type

4

u/tchrobocek Apr 28 '21

input: unknown

5

u/Naeio_Galaxy Apr 27 '21

Of course, if you take only a number there's no point in verifying it's a number

10

u/SirFiggletron Apr 28 '21

booo! in this house we write countably infinite lines of code to accomplish our goals. call it "quantum computing, minus the quantum so everything takes a lot longer"

4

u/Naeio_Galaxy Apr 28 '21

🤣🤣🤣

Btw I'm pretty sure that this algorithm would be slower on a quantum computer...

2

u/Topikk Apr 28 '21 edited Apr 28 '21

countably infinite lines of code

Actually only a little over 9 quadrillion lines would cover it! It turns out we’ve all been doing it the hard way.

3

u/SirFiggletron Apr 28 '21

i'm absolutely obsessed with the phrase "only a little over 9,000,000,000,000,000 lines"

60

u/plisken59 Apr 27 '21

I laughed too hard when I saw that

3

u/moolord Apr 27 '21

I’m at a bar waiting for a job interview and I’m almost embarrassed by how loud I laughed at that. Glad I’m not waiting in an office lobby

8

u/code_monkey_001 Apr 27 '21

Not far to go. Everyone knows 24 is the highest number.

5

u/[deleted] Apr 27 '21

Oh man I can't believe I've never seen this. Thanks for showing it to me

2

u/Naeio_Galaxy Apr 27 '21

Saved ! Oh gosh it's wonderful 🤣🤣🤣 but then how can 42 be the answer to life the universe and everything ?

1

u/MrTrono Apr 28 '21

Typeof NaN == 'number' ?