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, Arrays and Objects Simplify Repetitive Tasks with Loops Create a for Loop

Tine Jakomini
Tine Jakomini
2,494 Points

Please help !

.

script.js
for ( var counter = 0; counter < 156; counter += 4)  {

} if (counter < 156)  {
      console.log(counter);
}

1 Answer

The first error message you receive is Bummer: The console.log() method never ran. This is due to the closing bracket right before your if statement. That bracket should go to the very end of your code.

The if statement is unnecessary since you already have a condition included in your loop so you can remove that.

The instructions state log the numbers 4 to 156. So initialize counter at 4. Loop to 156 inclusive which means counter <= 156. And you are to log all numbers so they increment by one. The updated code is as follows:

for ( var counter = 4; counter <= 156; counter ++)  {
      console.log(counter);
}
Dario Bahena
Dario Bahena
10,697 Points
counter++ // good
counter ++ // not ideal