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 trialVincent Casilla
2,709 PointsHave the right code, but it wont run.
This code console logs numbers 5-100 but it wont let me pass it through ugh.
//! For Loop
for (let i = 0; i < 100; i++) {
if (i < 5) {
continue;
}
console.log(i);
}
Mod edit: added markdown for code readability. Check out the "markdown cheatsheet" linked below the comment box for syntax examples.
2 Answers
Cameron Childres
11,820 PointsHi Vincent,
Your code logs the numbers 5-99 since the condition of the for loop is "i < 100". If you change this to "i <= 100" then 100 will be included and you should be able to complete the challenge.
Brandon White
Full Stack JavaScript Techdegree Graduate 34,662 PointsHi Vincent,
Your solution is an interesting one, but it works great. Nice job. But it doesn’t actually log all 5-100.
for (let i = 0; i < 100; i++) {
if (i < 5) {
continue;
} console.log(i);
}
It logs 5-99. If you look close you’d probably figure this out on your own, but once i
becomes 100, the i < 100
part of the for loop no longer evaluates to true
, therefore the code in the code block isn’t executed, and i
is not logged to the console.
That’s happened to me plenty of times.
Great work here! Keep it up, coder!
Vincent Casilla
2,709 PointsThank you! Could not spot this for the longest time!
Vincent Casilla
2,709 PointsVincent Casilla
2,709 PointsThank you, I missed that one!