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 trialMatt Fredericks
5,399 PointsNot sure what's wrong for( var num = 4; num < 156; num+=1) { console.log(num); }
Not sure what's wrong with the for loop
for( var num = 4; num < 156; num+=1)
{
console.log(num);
}
3 Answers
Chris Thomas
Front End Web Development Techdegree Graduate 34,909 PointsYou're close but you're actually only logging numbers 4 through 155. The way the logic of your for loop works is that it starts at 4 and keeps looping for as long as the variable is less than 156. When it reaches 156, it stops, and never logs it. So you want to go to 157.
for (var num = 4; num < 157; num++) {
console.log(num);
}
Clayton Perszyk
Treehouse Moderator 48,850 PointsHey Matt,
Your loop seems to be working correctly; It is logging the numbers 4 to 155. Were you trying to achieve something else?
Best,
Clayton
james south
Front End Web Development Techdegree Graduate 33,271 Pointsyou will be one number short with this loop. you are very close. you need to make a minor tweak to include the missing number. run this code in your console and you will see.