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

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

here's my code : for(var i = 4; i <= 156; i+=1){ console.log(i + ' '); } my code output is correct but the error still appear. I hope someone can help me with this.

script.js
for(var i = 4; i < 157; i+=1){
  console.log(i + ' ');
}
Dave StSomeWhere
Dave StSomeWhere
19,870 Points

What's up with the space? Does the challenge ask for a space?

2 Answers

Camilo Lucero
Camilo Lucero
27,692 Points

You don't need to add the empty space after the number. Concatenating a number with a string will return a string, so 1 + ' ' would be equal to the string '1 ' and not to the number 1.

The challenge asks you to print the numbers from 4 to 156, but your solution is returning strings, not numbers. Delete the empty space that you are adding after the number, it should work fine.

Yeah I already figure out that one. but thanks anyway to your help camilo.