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 don't understand what I am doing wrong with this for loop.

When I test my code out and preview it. It prints out the numbers 4 to 156 to the console. Am I missing something or does it want it done a specific way that I haven't thought about yet?

script.js
var numbers = '';


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

2 Answers

Hey, I see why you did it that way, makes sense. The error message kind hints that console.log needs to be called for every number. Also you start with 1 when they want 4. Otherwise its good.

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

Thank you!