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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Tural Rzazade](https://uploads.teamtreehouse.com/production/profile-photos/11591276/micro_Tural_Rzazade.jpg)
Tural Rzazade
3,750 PointsSolved the task in the last part
const regionDown = prompt("Where are you from, Europe or America?");
const region = regionDown.toUpperCase();
if (region === "AMERICA") {
function getArea(width, length, unit = "sq ft") {
const area = width * length;
return `${area} ${unit}`;
}
} else {
function getArea(width, length, unit = "sq ft") {
const area = width * length;
return `${area} ${unit}`;
}
}
I struggled first to figure out the way for getting unit based on the region that user is from, but then I used a conditional statement. I knew that I had to use conditional smth to get that but I guess "little things" (indentation/ quotes/ misspelled words) were making me think that it doesn't work.
1 Answer
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsIt's not clear why you would use a conditional here, since both branches contain exactly the same code. Did you perhaps intend for the 2nd definition to set the default unit to "sq meters" instead?
Also, instead of having two completely different definitions of the function, you could have just one and make use of the region setting inside the function code, or in the way the function is called.