Here's my code for Codecamedy's FizzBuzz lesson
var i;
for ( i = 1; i > 20; i++ ) {
"hello"
if ( i % 3 === 0 ) {
if ( i % 5 === 0 ) {
"FizzBuzz";
}
else {
"Fizz";
}
}
else if ( i % 5 === 0 ) {
"Buzz";
}
else {
i;
}
}
I'm trying to first test whether or not the number (i) is divisible by 3. If it is, I then want to check whether it is also divisible by 5. If both conditions are true, I want it to say "FizzBuzz". If only the first condition is true, it should say "Fizz". Then, after determining that i is not divisible by 3, it should check whether i is divisible by 5 and show "Buzz" if that's the case. Failing all divisibility, it should just show the number.
As I expected... it doesn't work as expected. What terribly embarrassing mistakes have I made?
After considering all the other very good answers here:
Since you're "stuck on step 1" with the code you've provided, I assume you did the same mistake I did after clicking your link and reading the instructions. Step 1 doesn't actually ask you to solve the Fizzbuzz problem. To pass this step, you only have to do something much simpler. Read the (not very good) instructions again ;)