3 and the good (FizzBuzz)


#1

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 (!i % 3 === 0 || !i % 5 === 0){
console.log(i);
}
};


#2

Figured it out! Removed the else condition and switched i<20 -> i<21


#3

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