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 Calling a Setter Method

Thristen Jones
Thristen Jones
2,819 Points

Calculating area?

it says do pie(radius * 2) in the formula for area and this is exactly how i have it. "this.area = Math.pow(3.14, radius * 2)" but its saying im wrong.

Circle.js
class Circle {
    set radius(radius) {
      this.area = Math.pow(3.14, radius * 2)
      this.circumference = 2 * 3.14 * radius ;
      this._radius = radius
    }


}

const circ = new Circle();

1 Answer

Steven Parker
Steven Parker
216,744 Points

The instructions say the formula for area is area = π*r^2, which assumes that you know to apply the exponent first. Perhaps they should have written it as: π * (r^2). What the code above is doing is actually π ^ (r*2) instead.

π * (r^2) is what I meant in my previous answer when I described it without using the symbols as PI times (R squared).