Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
Created May 2, 2013 20:51
Show Gist options
  • Save PatrickJS/5505370 to your computer and use it in GitHub Desktop.
Save PatrickJS/5505370 to your computer and use it in GitHub Desktop.
Super-optimised version of FizzBuzz
// Super-optimised version of FizzBuzz
var array = [];
array[3] = array[6] = array[9] = array[12] = "Fizz<br>";
array[5] = array[10] = "Buzz<br>";
array[0] = "FizzBuzz<br>";
var str = "";
for( var i=1; i<=100; ++i) {
str += array[ i%15 ] || i + "<br>";
}
window.onload = function() {
document.body.innerHTML = str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment