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 trialrayjens code
882 PointsCreate a for loop that logs the numbers 4 to 156 to the console. To log a value to the console use the console.log( ) me
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 dont have idea how to start the 4
for(var i=1;i<4 i<=156; i+=1){
console.log(i);
}
2 Answers
Steven Parker
231,236 PointsA for loop has three clauses:
The first one is the initialization. That's where you set your loop variable to the first value you want to use. You currently have it set to 1, but perhaps you want 4 instead.
The second clause should have just one conditional expression. You have two in there right now. You want to keep the one that will stop the loop after it reaches the highest value you want.
Lynn Collins
10,080 Pointsok...now I am feeling sorry for myself.
Steven Parker
231,236 PointsIf you're a step closer to mastery ... that's a happy thing!