Introduction to objects1(3. and...)


#1

For the life of me i can't get this goddamn thing to stop printing zero. Any help with this is GREATLY appreciated. Incredibly frustrated that solution wasn't solution.

Oops, try again. It looks like you printed out the wrong number of items.


my code:  
for(i = 0; i <= 20; i++) {
    if(i % 5 === 0 && i % 3 === 0) {
        console.log("FizzBuzz");
} else if(i % 5 === 0) {
    console.log("Buzz");
} else if(i % 3 === 0) {
    console.log("FizzBuzz");
} else {
    console.log(i);
}
};

result:   FizzBuzz
1
2
FizzBuzz
4
Buzz
FizzBuzz
7
8
FizzBuzz
Buzz
11
FizzBuzz
13
14
FizzBuzz
16
17
FizzBuzz
19
Buzz


#2

I don't remember the instructions exactly. Does the loop need to start at 0 and end at 20 or start at 1 and end at 21?


#3

You need to adjust your starting point to 1 instead of 0.

And numbers divisible by three should print Fizz, not FizzBuzz.


#4

The loop needs to start at 1 and end at 20.


#5

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