# FizzBuzz code not working

#1

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>I don’t understand why this code is not working, I just know that it returns nothing. Can someone please explain it to me?

```

var counter = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];

var FizzBuzz;
var repeat = function() {
for(x = 0; x < counter.length; x++) {
if ( counter % 3 == !0 && counter % 5 == !0) {
FizzBuzz = counter;
} else if ( counter % 3 == 0 && counter % 5 == 0) {
FizzBuzz = “FizzBuzz”;
} else if ( counter % 3 == 0 && counter % 5 == !0 ){
FizzBuzz = “Fizz”;
} else if ( counter % 5 == 0 && counter % 3 == !0 ) {
FizzBuzz = “Buzz”;
};
};
return FizzBuzz;
};

``<do not remove the three backticks above>``

#2

Hi,

You have to include the return keyword in each of your if else statements. So where you have written Fizzbuzz= “example”; you need to replace it with return “example”;. This will then return the string with text to the output. Also it may be worth having another look at how you have done the and arguments in the if else’s. They currently all have an && logic argument and only the fizzbuzz actually needs it as it is divisible by 3 AND 5. If you want more code I can paste but will take the fun out!

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

simplified my code and made it work so OORAH. Thanks for the help.