Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!!!