Part 0 - Getting Started
Part 1 - Basics
- 4 - Variables
- 5 - Operators
- 6 - Functions
- 7 - Conditional Statements
- 8 - Arrays
- 9 - Loops
- 10 - Exercise: FizzBuzz
- 11 - Congratulations
Part 2 - The Browser
Useful Links
Step 10 - Exercise: FizzBuzz
Time has come for a classic exercise. Yaay!
Count from 1 to 50 and print the numbers out:
- If a number is a multiple of three, print ‘Fizz’.
- If it’s a multiple of 5, print ‘Buzz’.
- If it’s a multiple of 3 and 5, print ‘FizzBuzz’.
- For everything else, print the number itself.
Note: You may wish to use arithmetic operator remainder (%):
for( var i = 0; i < 50; i ++){
if(i % 15 == 0){
console.log("FizzBuzz");
}
else if(i % 3 == 0){
console.log("Fizz");
}
else if(i % 5 == 0){
console.log("Buzz");
}
else {
console.log(i);
}
}