Fizzbuzz party fun! Error


#1

Hi there,

I need some help with my code in the FizzBuzz Objects section. Here's the info:

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

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

Please let me know what I'm doing wrong.

Cheers,

E


#2

Typically you'd start debugging by considering how the current behaviour differs from what you want - so what is that difference? (or when asking describe what the problem is to save others from first figuring out what the problem is)


#3

The error that pops up says:

SyntaxError: Unexpected token for

is there a syntax issue with the loops themselves, or is the problem elsewhere?


#4

You could temporarily remove stuff to make it more manageable, and then compare what's left to a reference (motivate to yourself why you'd be able to write what you did)

In this case it's pointing at something pretty specific, so you might consider what you meant with that part in that context


#5

I figured it out.

I removed: variable counting =

and left it as this:

for (i = 1; i <21; i++) {

if (i % 3 === 0 && i % 5 === 0) {
console.log("FizzBuzz");
}

else if (i % 3 === 0) {
console.log("Fizz");
}

else if (i % 5 === 0) {
console.log("Buzz");
}

else {
console.log(i);
}
};


#6

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