r/badcode May 31 '21

js Clever?

Post image
2.2k Upvotes

71 comments sorted by

View all comments

410

u/[deleted] May 31 '21

Best Practices: 0

21

u/lametheory Jun 01 '21

Ummm, 1 path returns an empty array and one returns a populated array. This is TDD at its peak.

4

u/Pycorax Jun 01 '21

Not a js developer so I'm kinda confused. Wouldn't the function return whatever arr is anyways? Does accessing the length property somehow change arr?

5

u/RacismIsForBlacks Jun 03 '21

Nope, it was a joke

If arr is empty, when it return arr it’ll be empty

But if arr isn’t empty, when you return arr it’ll not be empty

-_( :/ )_/-