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

Nick Pirini
Nick Pirini
4,186 Points

Who is this for-loop incorrect?

the code seemed to run fine on Atom; but it was incorrect for the assignment. Please enlighten me. Feeling frustrated.

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

2 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing great, but you got a little fancy with your output. You've put two blank spaces on either side of the counter you're logging out, which results in output they aren't expecting. If I remove the two blank spaces " " on either side of counter and the + signs, your code passes!

:bulb: It's always a good idea in these challenges to try not to do anything the challenge doesn't explicitly ask for. Even if functional, it can cause the challenge to fail. In cases where they are checking for output, it generally must be correct to the letter. This includes punctuation, spelling, capitalization and even spacing.

Hope this helps! :sparkles:

Nick Pirini
Nick Pirini
4,186 Points

Thanks so much. I really appreciate your help. You are the best person in the world for this moment in time. Yay!!!