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'm stuck again

i'm stuck with the loops. I don't know why

script.js
for (var i = 4; i= > 4; i = 156) {
    console.log (i);
}
Kishan P
Kishan P
9,921 Points

Hey, Kim

It's okay to get stuck and feel like u don't know anything. that's how i felt when i was working on that and TBH i was stuck for 2 weeks and after watching those videos too many times i finally figured it out...

2 Answers

hi!, for loops work like that: u need to declare from where i start like u did, then u need to make a statement when the loop will stop which will happen in i<=156 and after that u need to increment the i in order to loop though each number. watch the videos again it will be more clear. if this answer helped u mark as best answer

Oenas Vaes
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree seal-36
Oenas Vaes
Front End Web Development Techdegree Graduate 17,319 Points

Hey Kim,

You're almost there! Try to read and re-read your for loop, to really understand what it does. That's a trick I use when I'm stuck. So in this case;

Variable i equals 4; if i is smaller or equal to 156; add one to i until it equals 156. If you have any more questions just go ahead!

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

Oenas