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 Practice Getters and Setters in JavaScript Practicing Getters and Setters Practice Creating and Accessing a Getter method

what 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

The task asks that you create an array called areas. You created one called area.

Thank you: :)