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 trial

JavaScript JavaScript Loops Working with 'for' Loops Create a for Loop

Have 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
Cameron Childres
11,818 Points

Hi 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.

Thank you, I missed that one!

Hi Vincent,

Your solution is an interesting one, but it works great. Nice job. But it doesnโ€™t actually log all 5-100.

app.js
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!

Thank you! Could not spot this for the longest time!