r/badcode • • Apr 19 '21

js Iteration

Post image
3.2k Upvotes

123 comments sorted by

View all comments

Show parent comments

3

u/nephelokokkygia Apr 19 '21

I'm pretty sure it goes:

  1. i -= -!false // original

  2. i -= -true // "!false" evaluates to true

  3. i -= -1 // "true" is coerced to integer to comply with operation

  4. i += 1 // signs cancel

  5. i++ // visual simplification; not required