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

Jose Medina
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jose Medina
Front End Web Development Techdegree Graduate 15,656 Points

The console should write out 4 the first time in the loop and 156 the last time through the loop.

I wrote out the code and tried it in the workspace on a separate window and it works as intended. It DOES write out 4 and 156 in the console.log and everything in between? I'm not sure what I'm missing here.

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

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi Jose,

It might just be a simple difference in the string that the code challenge is looking for. I notice you're using the <= operator to make sure all the numbers you need are showing up :)

Try simply removing the string from the console.log method so you're only passing in the reference to the variable! :-)

for ( var i = 4; i <= 156; i += 1 )

try i++