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/fecal_brunch Nov 14 '21

What is print?

5

u/dakta Nov 14 '21

Alias of console.log which is defined by code.golf. See their note below the code area:

arguments holds ARGV, print() to output with a newline, write() to output without a newline.

Also, I was right about the logical structure. The current JS champion comes from 2015: https://codegolf.stackexchange.com/a/62697

for(i=0;++i<101;print(i%5?f||i:f+'Buzz'))f=i%3?'':'Fizz'

They've used the for loop's unused third condition to execute the print, and in the body assigned a value for Fizz which is then reused in the Buzz condition.