Help! and the good (FizzBuzz)


#1



Help, please can anyone show me what is wrong?
It keep showing me this
Oops, try again. It looks like you printed out the wrong number of items.


var FizzBuzz = function() {
    for(var i = 1; i <= 20; i++) {
        if ((i % 3 === 0) && (i % 5 === 0))
        {
            console.log("FizzBuzz");
            } 
            else if (i % 3 === 0)
            {
                console.log("Fizz");
                }
                else if (i % 5 === 0)
                {
                    console.log("Buzz");
                    }
                    else
                    {
                        console.log(i);
                        }
        }
    };


#2

You just need to call the function!
At the end of your code, (outside of the function), call it by running FizzBuzz()

Hope this helps. :slight_smile:


#3

Thanks so much Kyleaw, It helped:grinning:


#5

Quick question Kyleaw, I know you can go on to the next part if you just start off with "for(....etc" instead of making it a function.

Is it better practice to make it a function or either way it doesn't matter?


#6

Variable names cannot start with capital letters?


#7

You don't have to make a function, the exercise never asks for it

In such a simply program, i don't see why a function would be needed

@codiusy, variable names can start with capital letter, the question is, why would you?


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.