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

Sergey Filimonov
5,878 PointsFor loops won't work
Here is the task: Create a for loop that logs the numbers 4 to 156 to the console. To log a value to the console use the console.log( ) method.
I've written the loop but it doesn't work :(
for ( var i = 1; i > 4 && i < 156; i += 1 ) {
return i;
}
console.log(i);
2 Answers

Adrian Patrascu
15,279 PointsHi Sergey,
Your loop will not work because the condition in the for will be false for the first 3 numbers. I would recommend initializing i = 4 from the beginning when you set var i=1 and then comparing with 156.
So for (var i=4; i <156; i +=1) { return i; }
Thank you, Adrian

Sergey Filimonov
5,878 PointsThanks Adrian! Now I got it!
for ( var i = 4; i <= 156; i += 1 ) {
console.log(i);
}

Sergey Filimonov
5,878 PointsHm it's not showing it correctly for some reason. Here is the correct code http://take.ms/spsjJn