3... And the Good (not so good since I need some help!) Exercise


#1

Hey Code Academy fam:

I can't figure out what's going wrong with my code here...

https://www.codecademy.com/en/courses/spencer-sandbox/0/3?curriculum_id=506324b3a7dffd00020bf661#

Any help would be appreciated. I keep getting a syntax error saying there's an unexpected token {

for (var i = 1; i >= 20; i ++) {
    
    if (i % 3 === 0) {
        console.log("Fizz");
    } 
    else if (i % 5 === 0 && i % 3 === 0) {
        console.log("FizzBuzz");
    } 
    else if (i % 5 === 0) {
        console.log("Buzz");
    } 
    else (i) {
        console.log (i);
    }
};

#2

Else statement should just be

else {
    //Do something
}

So remove the (i).


#3

Thank you dattatcat; keep killing it! You da man.


#4

Hi. The for syntax is like this:
for(initialValue; endValue; incrementValue){
//add your code here
}

Remove the ";" after you finished the "for" statement.


#5

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