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

Jiten Mehta
Front End Web Development Techdegree Graduate 21,209 PointsStruggling with for loops code challenge
The challenge asks to log out every number from 4 to 156.
Thie works in workspaces, but for some reason, it does not work in the code challenge. I can't see where I am going wrong? Help, please!
Code is below.
Thanks, Jiten.
var html='';
for ( var i = 4; i <= 156; i +=1 ) {
html += ' ' + i + ' ';
}
console.log(html);
2 Answers

Martin Jones
Front End Web Development Techdegree Graduate 44,227 PointsYour code will display every number from 4 to 156, but as one big string.
The challenge is to log out each number individually. To do this, simply move the console log to within the for loop, as shown below:
var html='';
for ( var i = 4; i <= 156; i +=1 ) {
console.log(i);
}

Jiten Mehta
Front End Web Development Techdegree Graduate 21,209 PointsAhh I see, I miss interpreted the question. Cheers Martin!

Martin Jones
Front End Web Development Techdegree Graduate 44,227 PointsNo worries, yeah you still got the concept of the loop itself right :D