I have a simple fizzbuzz here:
var num = 1;
while (num <= 20) {
switch(true){
case(num%3 === 0 && num%5 === 0):
console.log('fizzbuzz');
break;
case(num%3 === 0):
console.log('fizz');
break;
case(num%5 === 0):
console.log('buzz');
break;
default:
console.log(num);
}
num++;
}
What is the meaning of the comparison to 0
after the modulus in this line: num%3===0
?
Why isn't it just num%3
?