FizzBuzz - and the good not working


#1

for(var liczba = 1; liczba < 21; liczba++){
if((liczba % 3) == 0){
if((liczba % 5) == 0){
console.log(liczba + ' ' + 'FizzBuzz');
}
else {
console.log(liczba + ' ' + 'Fizz');
}
}
else if((liczba % 5) == 0){
console.log(liczba + ' ' + 'Buzz');
}
else {
console.log(liczba)
}

};

I am getting an 'unexpected token else' warning... Is anything wrong with this code? Yes i know i can do this by if % 3 && % 5 , else if %3 and else if %5, but in my opinion this way is also right. Any idea why this code is not working?


#2

more transparent version of my code :slightly_smiling:


#3

Code is good, just try not to print out number liczba when you have a word like Buzz, Fizz, and FizzBuzz. Just do console.log("Buzz")


#4

Here, you are printing (ex.) "3 Fizz", when in reality you are being asked to replace the number 3 with the string "Fizz". Meaning that you should, instead of
console.log(liczba + ' ' + 'Fizz')
just
console.log('Fizz')


#5

Also make sure you have "===". You have only two == on line 2,3, and 10. Just an observation.