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

Simohamed ALAOUI
Simohamed ALAOUI
3,580 Points

Can you guys help!

What am I doing wrong?!

script.js
for( var i = 4; i <=156; i += 1 ) {
}
console.log(i);

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Simohamed ALAOUI

You've almost got it. If you have a look at the error the challenge is returning to you when you submit your code:

Bummer: You need to log out EVERY number from 4 to 156 to the console. Your loop calls the console.log() method 1 times.

It is telling you that console.log() is only called once. This is because you have it outside of the loop. It needs to be inside the loop, so that it runs each time the loop is called.
Once you correct that small error, the task will pass.

Nice work. :) :dizzy:

Simohamed ALAOUI
Simohamed ALAOUI
3,580 Points

Jason Anders Thank you so much for your help