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

Nayoon kim
Nayoon kim
3,098 Points

Can you tell me an answer to this simple 'for loop' question

I just don't get what is wrong, maybe I should put console.log(i); inside of the {}

script.js
for (var i = 1; 3<i<157; i++1) {

}

console.log(i);

2 Answers

Justin Cantley
Justin Cantley
18,068 Points

Yes, you do want to move the

console.log(i);

inside of the braces. Also when incrementing the variable 'i' you don't want to write

i++1

The correct syntax can be 1 of the following:

i = i + 1;
i += 1;
i++;

Also instead of writing

3 < i < 157;

just start your variable i at 3 like so:

(var i = 3; i < 157; i++;)

Hope this helps!

Nayoon kim
Nayoon kim
3,098 Points

ah I see, thank you so much !

this one's a duplicate question. I urge you to delete this one.

Thank you, Nafis Faisal