I'm having an issue making my loop test against two conditions simultaneously.
for (var result = 0; result <= 100; result ++)
if (result % 3 == 0)
console.log ('Fizz');
else if (result % 5 == 0)
console.log ('Buzz');
else console.log (result);
How can I build a third condition that tests if result is divisible by 3 AND 5?
else if ( result % 5 == 0 && result % 3 == 0)
console.log ('FizzBuzz');
else console.log (result);
This was my solution and 'FizzBuzz' didn't make it the console at all! Why didn't that solution work?
Aucun commentaire:
Enregistrer un commentaire