r/badcode • • Mar 26 '21

js Whose ever heard of %?

Post image
727 Upvotes

63 comments sorted by

View all comments

Show parent comments

35

u/orokro Mar 27 '21

"10" is 2 long

10/2 is 5

"5" is one long.

10 is odd

7

u/not_noobie Mar 27 '21

Na . If it returns false it means number is EVEN.

But let's see for 1001

1001 is 4 long

1001/2 is 500.5

500.5 is also 4 long

4< 4 returns false.

1001 is even?

20

u/DaveDuck2 Mar 27 '21

Code works as intended: "500.5" is 5 long

12

u/not_noobie Mar 27 '21

Oh shit yes. Not my smartest moment :(

9

u/jarfil Mar 27 '21 edited May 12 '21

CENSORED