Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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 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