# Missing 15?

#1

No idea why there's a 15 missing in the console log despite doing exactly what the program has been telling me to do. I've tried quite a lot yet for some reason, the console log thinks that 3 is divisible by 5? I've switched around the code for Fizz, Buzz and FizzBuzz and it still doesn't work. I also tried making an if statement on:

if **num % 3 then**
console.log("Fizz")
console.log(num)

(Pseudo code above)
Yet I apparently 3 is a modulo of 3 yet when I done this in a calculator, it just says 0. There is no remainder.

"Oops, try again. It looks like you printed out the wrong number of items. "
Console Log:
CONSOLE BEGIN
Fizz
1
Fizz
2
Buzz
3
Fizz
4
Fizz
5
Buzz
6
Fizz
7
Fizz
8
Buzz
9
Fizz
10
Fizz
11
Buzz
12
Fizz
13
Fizz
14
Fizz
16
Fizz
17
Buzz
18
Fizz
19
Fizz
20
CONSOLE END

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

#2

There're many mistakes in this code..

Your for loop works fine.
But there are many problem with your `if/else if/else` clause.

``````  if(num % 3) {
console.log("Fizz");
console.log(num);
}``````

Remove `console.log(num);`
and I think you're testing if `num` is divisible by 3 or not?
Then improve this line by writing this..
`if(num % 3 === 0)`

Do same thing for ..

``````else if(num % 5) {
console.log("Buzz");
console.log(num);
}``````

Now in this block..

``````else if(num % 5 && 3) {
console.log("FizzBuzz");
console.log(num);
}``````

First remove this `console.log(num);`
then ..
`else if(num % 5 && 3)`
You have to test like this..

`num % 3 === 0 && num % 3 === 0`

Last part..
Introduce an else clause and put `console.log(num);` inside it.

Last but not the least..
Then there is one problem that is related to correct flow of control.

First fix them (the points I mentioned) then We will focus on last part of problem.

#3

Fixed those mistakes.

#4

can you post your current code?

#5

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