3.And the good


#1

I was wondering why I have to put "FizzBuzz" first in order to get this code to work:

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


#2

We need to rule out the AND possibility first else it will never be seen. If we test just the 3, and it passes, then the 3 AND 5 state will not be tested. Likewise if we test just the 5.

should be just else.


#5