3/33 "Oops, try again. You printed Fizz when you should have printed FizzBuzz"


#1


https://www.codecademy.com/en/courses/spencer-sandbox/0/3?curriculum_id=506324b3a7dffd00020bf661#

hey guys, i got an error message which says:

"Oops, try again. You printed Fizz when you should have printed FizzBuzz"

and i didn't know why i got this!!! since my code is correct... i think.

here is my code :


for (var i = 1; i <=20; 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

well, given a number which is dividable by 3 and 5, is also dividable by 3, the if clause will run. Once if execute, else if/else won't run anymore

You should check if i is divisible by 3 and 5 as first condition


#3

thank u , good to know that..and i've solved it