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.

JavaScript JavaScript Functions Arrow Functions Create Functions Using Arrow Syntax

I'm attempting to translate the getArea function expression into an arrow function.

When I call getArea and pass in the "units" parameter (sqfeet, sqmeter, etc.) I get "sqfeet/sqmeter undefined". What am I missing about passing in the unit?

function getArea(width, length, unit) { const area = width * length; return ${area} ${unit}; } getArea(36, 60, sqfeet);

2 Answers

Steven Parker
Steven Parker
220,425 Points

This is not related to converting to an arrow function, but t looks like you need to supply a string for the units argument.

getArea(36, 60, sqfeet);    // current code, sqfeet is undefined
getArea(36, 60, "sqfeet");  // fixed

Thank you! I discovered that about 10 mins after posting. Felt pretty silly...

Thanks again,


Steven Parker
Steven Parker
220,425 Points

Seth Lewis — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!