3. ... And the good!


#1

Hello everyone,

I’ve been stuck on this exercise for quite some time and I haven’t been able to figure out what’s wrong with my code even after looking at the other threads. I keep getting the error message “It looks like you printed out the wrong number of items."

var num = 1;
var totalTimes = 20;

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

Is there something that I’m missing?

Thank you for your help!


#2

This might help you..


#3

Thank you very much!

I had read that thread 4-5 times and for some reason it didn’t register that I had the order wrong!

I’ve switched the order and it has now worked!


#4

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