Wednesday, December 4, 2013

my solution to the Fizz Buzz programming interview question

This is my solution to the Fizz Buzz programming question / challenge as posted on this web page.
Click here to output the results.
<script>
  for (i=1; i < 101; i++) {
   if ( (i%3 == 0) && (i%5 == 0) ) { document.write(i + " FizzBuzz<br>"); }
   else if (i%3 == 0) { document.write(i + " Fizz<br>"); }
   else if (i%5 == 0) { document.write(i + " Buzz<br>"); }
   else { document.write(i + "<br>"); }
  }
</script>

No comments:

Post a Comment