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 trialLarry Young
4,356 PointsArrow function syntax related to keyword return.
Is it true that removing curly braces when there is only one line of code in the function will always result in the browser interpreting that as a return, or implying a return? Could that possibly lead to any problems to look out for? For example, what you are saying is
const printDate = date = () => console.log(date); //this is "techinacally" still 'returning' the console.log(date);
const printDate = date = () => {console.log(date)}; //this is just running console.log(date); with no implied return
const printDate = date = () => {return console.log(date)} //would this break?;
2 Answers
jamesjones21
9,260 Pointsactually the bottom 2 will break as you are forgetting a closing parenthesis on the closing of console.log :)
benyoungblood
10,062 PointsYes, that is totally fine. Only works with arrow functions.
Larry Young
4,356 PointsLarry Young
4,356 Pointslol whoops didn't catch that thanks :P