Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Jong Kim
6,145 PointsWhy do we need a bracket even though we have parenthesis?
Why don't we just put everything inside of parenthesis?
for example,
Why can't we just put everything inside of parenthesis?? for (i = 0; i <= 5; i += 1; text += i + ' ')
What is the purpose of separating a parenthesis and bracket?
Why do we have to write ' text += i + ' '; ' inside of bracket instead just write down into the parenthesis?
1 Answer

Steven Parker
221,291 PointsYou could certainly make it work that way, and technically, I'd call that a legitimate alternative solution.
But it's a rather unconventional way to construct a loop, and its purpose might not be as immediately clear to someone reading the code. So for that reason I don't think it would qualify as a "best practice".
However, I must admit that I have made loops like that myself on occasion.