Print all numbers divisible by 3 & 5 between 5 and 50

Print all numbers divisible by 3 & 5 between 5 and 50
0

#1

var count = 5;
while (count <= 50) {
if (count % 5 === 0 && count % 3 === 0) {
console.log(count);
}
count++;
}

This is what i am trying it shows only nbrs divisible by 5 but not 3.


#2

That is because your if condition checks if count is divisible by 5 AND divisible by 3. What numbers were you expecting to see displayed?


#3

Oh! Got it.

The error was in my head I was considering AND as OR.

:frowning:

Thanks!