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

I keep getting Bummer when the code is correct. I ran it in the Workspace and it worked perfectly.

On the For Loop exercise to console.log 4-156 my code is correct but it keeps saying I'm wrong. I ran it in the Workspace from the previous video and it worked perfectly. It wrote the numbers 4-156 to the console. for ( i = 4; i <= 156; i += 1 ) { console.log( i + ' '); }

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

1 Answer

Umesh Ravji
Umesh Ravji
42,386 Points

Hi John, it's just the space you are adding to each number, I'm not sure how the engine tests the output, but the solution is just to remove it. Also, make sure to include the var (or let/const) keyword when making variables, while it won't hurt here without it, in the future it may create issues :)

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

Thanks Umesh. I found that out also. Good comment on declaring the var in the For condition but the videos don't do that. Thanks for the insight!