Skip to content

Instantly share code, notes, and snippets.

@hodbby
Created June 13, 2012 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hodbby/2922328 to your computer and use it in GitHub Desktop.
Save hodbby/2922328 to your computer and use it in GitHub Desktop.
Fizz Buzz
<html>
<head><title>FizzBuzz</title></head>
<body>
<script type="text/javascript">
document.write ("Counting 1 to 100, when ever number devide in 3 it is fuzz, when number devide in 5 it is buzz and both are fizzbuzz... ");
document.write (" ");
for (i=1; i<=100; i++) {
if (i % 3 === 0 && i % 5 === 0) {
document.write(" FizzBuzz ,");
}
else if ( i % 3 === 0 ) {
document.write(" Fizz ,");
}
else if (i % 5 === 0 ) {
document.write(" Buzz ,");
}
else {
document.write(i);
document.write (" ,");
}
}
</script>
</body>
</html>
@nudnic
Copy link

nudnic commented Jun 30, 2012

you got i inside the for loop - use var i to define it (that's javascript convential)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment