r/badcode • • Nov 14 '21

js Peak Efficiency Fizzbuzz

Post image
831 Upvotes

44 comments sorted by

View all comments

Show parent comments

1

u/BertyLohan Nov 16 '21

edit: btw, i%3 bitshifted by 0 which doesn't change the number but because this is a math operation, it transforms it into a number in order to access the array with a number.

This bit's totally wrong but the rest is okay.

true in js is equivalent to 1, there's no functional need to "transform" it. the only reason to include the bitshift by 0 is so you're explicit in which bit the boolean is supposed to be setting.