How to Solve the FizzBuzz Code Challenge
tl;dr:How to solve a common programming question often brought up during the interview process.
"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'."
<script>
//Start the count from 1. Limit to 100.
for (var i = 1; i <= 100;) {
//Define write conditions based off divisibility
document.write((i % 3 ? "" : "Fizz") + (i % 5 ? "" : "Buzz") || i)
//Add line breaks for display purposes
+ document.write("<br>");
//Increment i for next loop
i++;
}
</script>