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

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey there,

You're on the right track, and the code looks good. :thumbsup: But, you are not doing what the instructions are asking, and that is why you are receiving the Bummer.

The challenge just wants you to use a for loop to log the numbers to the console. So, first, you need to delete the variable you created that was not asked for.
Next, you should be using console.log() in the loop, not a variable.
With that in mind, the code should be "logging" out each number separately, not adding them together (again, something the challenge did not ask you to do.)

So, you do have all the correct code, you just have some that isn't asked for and one line in the wrong place. Below is the corrected code for you to compare to the notes I provided above. I hope it helps.

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

Remember, Challenges are very specific and the instructions need to followed exactly or the Bummer will appear. Other than that... good job!

Keep Coding! :) :dizzy:

Ian Billings
PLUS
Ian Billings
Courses Plus Student 7,494 Points

Hi,

I think the problem is because the value of write has not been initialised. When I tried your code I was getting NaN printed to the console. Because write has no initial value, it doesn't know what to add on to j as it goes through the loop. Simply changing the first line to:

var write = 0;

meant that 12240 was printed to the console.