...And the good!


3. ...And the good!

I'm having trouble figuring out what I am doing wrong with my code. I'm getting a "SyntaxError: missing before statement" message error. Here is my code:

for (var i = 1; i <=20; i++){
if(i % 3 === 0) {
else(i % 5 === 0) {
else(i % 3 === 0 && i % 5 === 0) {



You can't have two else statements right after each other... Rather than suggesting that the first else be else if though, you need to think of the logic being if/else if/else statements... The computer looks for the first condition met and runs with it. For example, 15, (though it wants to be FizzBuzz), will print Buzz because it fits that scenario first. What you actually have to do is use FizzBuzz as the if, and then do else if and else with Buzz and Fizz, in whichever order you would like, as long as they come after FizzBuzz.


Ok, I got it to work now. Thank you!


No problem! Glad you got it working. :slight_smile:


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