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 Debug Arrow Function Expressions

Dennis Trinidad
Dennis Trinidad
Full Stack JavaScript Techdegree Student 759 Points

When to use curly braces and when not {}

I don't get it when we use curly braces and when not. I thought that if there is more than two lines of code we use them.

I thought its like that but last example of debug made me wrong :/

1 Answer

Steven Parker
Steven Parker
228,978 Points

Braces are typically used to define a code block, which can contain any number of code lines. There are some places where a code block is optional, such as after an "if" when only one statement is being controlled.

But other places, such as when defining the body of a function, the braces are always required.