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 trialandreavelayo
8,724 Pointswhat is wrong with my code. (Getter)
Here is the problem:
Create an array called areas with three elements so that the first element (areas[0]) holds the value of the area property of rect1, the second element holds the value of the area property of rect2, and the third element holds the value of the area property of rect3
class Rectangle {
constructor(width, length){
this.width = width;
this.length = length;
}
get area() {
return this.width * this.length;
}
}
const rect1 = new Rectangle(10, 5);
const rect2 = new Rectangle(6, 12);
const rect3 = new Rectangle(15, 20);
const area = [rect1.area, rect2.area, rect3.area];
1 Answer
KRIS NIKOLAISEN
54,971 PointsThe task asks that you create an array called areas. You created one called area.
andreavelayo
8,724 Pointsandreavelayo
8,724 PointsThank you: :)