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 trialOscar Arroyo
3,713 PointsI think my code looks pretty good but open to suggestions.
1 Answer
Steven Parker
231,248 PointsIt looks great! You're definitely getting "in the groove".
One small improvement you can make is skipping the creation of an intermediate variable if the only use for it is to return the result of a calculation. Instead, you can return the calculation directly. For example:
function rectangleArea (width, height) {
return width * height;
}
And you might not see this until later courses, but there's also a newer function definition syntax you can use that makes it a bit more compact yet:
const rectangleArea = (width, height) => width * height;
Oscar Arroyo
3,713 PointsOscar Arroyo
3,713 PointsThanks for the feedback! There seems to always be a way to shorten how much code you need to write to get the same results.