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 trialPaul Messmer
15,023 PointsWould this not work?
I keep getting this error "You need to log out EVERY number from 4 to 156 to the console. Your loop calls the console.log() method 152 times." this course seems to be very challenging and I am having issues knowing what I am suppose to do. I have yet to have a work space work the way it is suppose to when i follow along. Could it be from using let instead of var?
for ( let i = 1; i <= 156; i += 1) {
if( i > 4 ) {
console.log(i);
}
}
2 Answers
Steven Parker
231,275 PointsThe test "i > 4
" doesn't include 4, so that will be missing from the output.
But an even better way to do this would be to initialize "i" to 4 in the loop, and then you don't need the test at all.
Paul Messmer
15,023 PointsOh ok, I went back and made the changes and it worked flawlessly. Steven Parker Thank you so much!
Paul Messmer
15,023 PointsPaul Messmer
15,023 Pointswhat do you mean initalize "i" to 4 in the loop? thank you for your time in helping. Steven Parker
Steven Parker
231,275 PointsSteven Parker
231,275 PointsInitialization is the first of the 3 clauses of a "for" loop: