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

I am almost positive that this is correct but it keeps telling me parse error. could someone help please.

Also could you mention what a parse error is. Thank you!

script.js
for (var count = 3, count <= 157, count +=1){
  console.log(count);
}

3 Answers

Christopher De Lette
PLUS
Christopher De Lette
Courses Plus Student 7,139 Points

Hi Robert,

Instead of comma's separating the values in the for loop, you need to change them to semi-colon. Other than that works perfect.

Take care and Happy Coding!

Hi there -

The parse error means there was a problem in parsing (or reading) your code - it indicates a syntax error somewhere. Yours was tough to spot, but it lies in the start of your loop - instead of commas, there should be semicolons separating the parts of the 'for' loop declaration.

Aside from that, it wants the numbers to start from 4, so the count variable should start there too. It also wants you to stop after 156, so the second part of the loop declaration should be either "<= 156" or "< 157".

Hope this helps!

I changed the commas to semicolons and it still doesn't work. I still get parse error :/ I think it might've made it worse even.

Did you manage to get it? I just tried one more time, just changing the commas to semicolons and changing the numbers, and it worked. This was the code:

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

If it doesn't work, would you mind posting the code you're using? That way, we can figure out what's going on.

Raffael Dettling
Raffael Dettling
32,999 Points

Change the "," in the for loop to ";" and start at 4 not 3 also you want to count to 156 not 157^^

Raffael Dettling
Raffael Dettling
32,999 Points

I tried it and passed

for (var count = 4; count <= 156; count++){
  console.log(count);
}