Recently at an interview instead of checking whether or not I had a pulse, it was requested that I solve the FizzBuzz challenge in a language of my choice.
Naturally, I chose CSS.
“Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.”
It’s insanely simple.
To not display the number, for every 3rd and 5th element, set the font-size to 0.
To display Fizz for every multiple of 3, for every 3rd element, write “Fizz” with the :before pseudo element.
To display “Buzz” for every multiple of 5, for every 5th element, write “Buzz” with the :before pseudo element.
“FizzBuzz” comes for free whenever every 3rd and every 5th elements are the same.