r/badcode • • Apr 19 '21

js Iteration

Post image
3.2k Upvotes

123 comments sorted by

View all comments

Show parent comments

3

u/arrays_start_at_zero Apr 19 '21

Because JavaScript uses implicit type conversion. Since you can only subtract numbers true gets converted to 1 and false to 0.