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

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

Hi i keep getting this error and i have no idea what i am doing wrong

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

Here is my code

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

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

1 Answer

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey,

just log out the i variable inside of the loop like this:

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

And also note that even though you add i to your numbers variable inside the loop you're still logging out i instead of numbers in the end. Another mistake you made is that you just counted until 155 instead of 156.

Good luck!

Thanks this solved it once again i tought about it harder then it actualy was ^_^

Tobias Helmrich
Tobias Helmrich
31,603 Points

No problem! Yes, overthinking can often become a problem. :)