46/5000 How to use nested conditional in this exercise? Introduction to Objects I - 3


#1

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

    console.log(i);
}

}


#2

Since the value is tested against 3 and 5 by the time this conditional is encountered it will never be followed. One or the other will have been logged already. This check should be first in the pile.

if ( ... && ... ) {

}
else if ( ... ) {

}
else if ( ... ) {

} else {

}