Hi, what I'm doing wrong?


#1

On this code the computer doesn't read the second else if, what's wrong?
for(var 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

This is known as nesting, but it takes the else if and the else with it. The logging of i should be outside of the nest.


#3

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