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 trialTou Lee
6,608 Pointsfor loop Challenge
I'm confused. Can someone break this challenge down for me?
for ( var i = 1; i <= 156; i += 1 ) {
counter = 1;
}
console.log()
1 Answer
pi R
12,720 PointsHi ! I give you some hints:
You need to use the console.log() INSIDE your loop ! and here, your "counter" is the variable i. So it's this variable you need to log in the console. The way you declared your loop, it will run from 1 to 156. Be sure to set the proper value for i :)
Try this, if you can't figure it out i'll give you the code. Gl dude!
Tou Lee
6,608 PointsTou Lee
6,608 PointsOh wait, I think I get it! Thanks for not giving me the answer. I was hoping for only an explanation like you did.
for ( var i = 4; i <= 156; i += 1 ) { console.log(i); }
I get it now! The
i += 1
is looping to increment by 1 every time the condition holds true.pi R
12,720 Pointspi R
12,720 Points:) You're welcome!
Yep that's the good code =) You can also use "i++" instead of "i += 1" (it's the same !)
Enjoy the course ;) seeya