Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

How would I console.log 2 Numbers to run 46 times or whatsoever the task is asking

for ( let counter = 5; counter <=5; counter ++ ) {
  console.log( counter <=46);

1 Answer

The challenge question linked is asking you to log each number from 5 to 100 using a loop (this will actually turn out to be 96 logs)

Your counter starts at 5, which is good! This means 5 will be the first number logged. However, putting counter <= 5 means that the loop will only run while that condition evaluates to true. Since your loop iterator increments by one, this loop will only run once. Your second condition should say run until counter <= 100 evaluates false.

Lastly, your log statement should simply log the counter variable

console.log( counter );