Beginner FizzBuzz solution Is this a bad solution to the FizzBuzz thing? 

I decided to make it print "Fizz Buzz" for the numbers divisible by 3 and 5 just for practice/understanding. 

for (var n = 1; n &lt;= 100; n++) {
var output = "";
if (n % 3 == 0)
    output += "fizz";

if (n % 5 == 0)
    output += "buzz";

if (n % 5 == 0 &amp;&amp; n % 3 == 0)
    output = "fizz buzz";

console.log(output || n);
};
Indentation:

You're missing indentation in your code, you should space out each level of indentation.

For example:


for (var n = 1; n &lt;= 100; n++) {
var output = "";
if (n % 3 == 0)
    output += "fizz";



would become:

for (var n = 1; n &lt;= 100; n++) {
    var output = "";
    if (n % 3 == 0)
        output += "fizz";




Use braces

You should wrap your code in braces, so you don't cause any bugs unknowingly:

For example, you (or someone in future that maintains your code) might think this wouldn't log anything, however, "omg" is logged.


if (5 != 5)
    console.log("wow");
    console.log("omg")



Even Apple got caught out by one of these bugs.



Unnecessary logic:

In your block, you check whether the number is divisible by 3, then by 5, then by 3 and 5. You don't need to perform the last check of 3 and 5, the first two make up that one.



Leaving you with:

Implementing all those changes, you would end up with:

for (var n = 1; n &lt;= 100; n++) {
    var output = "";
    if (n % 3 == 0){
        output += "fizz";
    }
    if (n % 5 == 0){
        output += "buzz";
    }
    console.log(output || n);
};