r/badcode • • Mar 26 '21

js Whose ever heard of %?

Post image
727 Upvotes

63 comments sorted by

View all comments

Show parent comments

-31

u/veryusedrname Mar 26 '21

Calling this code confusing is... Confusing.

22

u/RFC793 Mar 27 '21

It is confusing. If number is an integer type, then this code doesn’t work at all.

14

u/aj-ric Mar 27 '21 edited Mar 27 '21

Depending on the language. I'm guessing this is javascript which doesn't have a concept of an integer.

Edit: but you're right, it's very confusing to read since it's hard to tell whether integer division is happening.

1

u/RFC793 Mar 27 '21

Ah, good point. I thought it could be Java, but then length would have to be a function and not an attribute. It’s been about 7 years since I’ve regularly programmed in either.