Thanks Codeacademy, this lesson made me feel like a genius!


#1


Just wanted to say thanks to codeacademy and all you guys in the threads who have replied to previous hangups I've run in to.

It felt so good to hit the save and submit code button and have all this code I wrote just work.

When I first wrote it and hit run, it did nothing, and I thought to myself "I've learned nothing" I scanned the code and couldnt think of what I possibly did wrong. I double checked to make sure I was using % properly, and if I had misspelled any variables... nothin'

Then I notice after I close my function up I never called it! I hit save and submit again and there it was!

Thanks everyone! On to the next lesson!


var gameCounter = 20;
var gameStart = 1;
var divisibleByThree = "Fizz";
var divisibleByFive = "Buzz";

var fizzBuzz = function() {
    for (i = gameStart; i <= gameCounter; i++) {
        if (i % 3 === 0 && i % 5 === 0) {
            console.log(divisibleByThree + divisibleByFive);
        } else if (i % 3 === 0) {
            console.log(divisibleByThree);
        } else if (i % 5 === 0) {
            console.log(divisibleByFive);
        } else {
            console.log(i);
        };
    };
};

fizzBuzz();


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.