Solution: Loops in JavaScript
Review the solutions to the tasks from the loops challenge.
We'll cover the following...
Solution 1
Here is a possible solution for checking if the number is a multiple of or .
Press + to interact
for (let i = 1; i <= 100; i++) {if (i % 3 === 0 && i % 5 === 0) {console.log("FizzBuzz");} else if (i % 3 === 0) {console.log("Fizz");} else if (i % 5 === 0) {console.log("Buzz");} else {console.log(i);}}
Explanation
-
Line 1: The for loop ...