Answers for "Using Math Functions in an IF statement"

0

Using Math Functions in an IF statement

for (i=1; i<21; i++) {

    if(i%3 === 0 && i%5 !== 0) {
        console.log("Fizz");
    } 

    else if (i%5 === 0 && i%3 !== 0) {
        console.log("Buzz");
    }

    else if (i%5 === 0 && !i%3 === 0) {
        console.log("FizzBuzz");
    }
    else {
       console.log(i); 
    }
}
Posted by: Guest on June-26-2021

Browse Popular Code Answers by Language