I am going through codeacademys JavaScript tutorials as i am new to it. The tutorial asks for the following:
Print out the numbers from 1 - 20.
The rules:
The check for both 3 and 5 must be first, otherwise the two other statements are true already and give separate logs. Now you print FizzBuzz in a single console.log statement.
for (i=1; i<=20; i++) {
if (i%5==0 && i%3==0) {
console.log("FizzBuzz");
} else if(i%3==0) {
console.log("Fizz");
} else if(i%5==0){
console.log("Buzz");
} else {
console.log(i);
}
}