Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Create a for Loop

Why is this wrong?

Bummer: There was an error with your code: SyntaxError: Parse error

for (var = i; 4<=i<=156; 1=+ i) {
 console.log (i) 

1 Answer

Steven Parker
Steven Parker
230,024 Points

Theres a few different syntax issues here:

  • var = i :point_left: the variable name must follow "var", and come before the equal-sign
  • the value being assigned to the var goes on the right of the equal-sign
  • 4<=i<=156 :point_left: you cannot test a single variable with two operators at the same time
  • but you can combine two individual tests with a logic operator :point_right: 4<=i && i<=156
  • 1=+ i :point_left: a "mirror image" of what you probably intended :point_right: i += 1