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 trialChristian Higgins
15,758 PointsBelow is a way to not name a function variable, but is it a best practice?
clockSection.textContent=getTime();
setInterval(() => clockSection.textContent=getTime(), 1000);
Would it be longer than just using:
tickClock();
, so that's why you wouldn't use it?
1 Answer
Steven Parker
231,261 PointsSure, it's shorter, but it also saves you from repeating the same assignment code. That's in keeping with the best-practice "DRY" (Don't Repeat Yourself) principle.
Also, when an arrow function contains more than just an expression (as this one has an assignment), you should use the "long form" where you place braces around the function body. In this case, you could also place parentheses around the assignment to cause it to be interpreted as an expression, but that's rather esoteric and not nearly as clear.