Let me share my code from the FizzBuzz lesson on Codecademy:
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;
}
}
In my code, I aim to check if a number (i) is divisible by 3 before determining if it's also divisible by 5. If both conditions hold true, it should output "FizzBuzz". For cases where only the first condition applies, it's supposed to print "Fizz". If neither are divisible, but i is divisible by 5, it will display "Buzz". And as a last resort, it simply shows the number itself.
However, upon running the code, the results were not what I expected at all! Can you spot any glaring mistakes that I might have overlooked?