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 trialJan Oberreiter
78,020 Pointsstill cannot solve the second question?
I figured the first out (after I cheated and looked it up), but from there, I cannot solve the second one ....
class Circle {
set radius(radius){
this._radius = radius;
this.area = 3.14 * Math.pow(radius, 2);
this.circumference = 2*(3.14)*radius;
}
}
const circ = new Circle();
4 Answers
Steven Parker
231,248 PointsTask 2 is easier than task 1, since there's no calculations this time.
Here's a hint: The setter stored the radius, the getter will just return the value that you stored.
Jan Oberreiter
78,020 PointsThank you for your answer, it is still getting me mad, I just don't get it, I am thinking of starting JS all over again like in the middle ... thank you very much .... regards, an.
Steven Parker
231,248 PointsSo were you able to solve it with the hint? If not, please show the code you tried.
Jan Oberreiter
78,020 PointsHello Steve, I finally managed it, but I habΓΌve to admit, I just tried around till I had it, but I still don't understand it, my code:
class Circle {
set radius(radius){
this._radius = radius;
this.area = 3.14 * Math.pow(radius, 2);
this.circumference = 2*(3.14)*radius;
}
get radius() {
return this._radius;
}
}
const circ = new Circle();
```javascript
Steven Parker
231,248 PointsYou did get it exactly right! Your "get" method returns the value that was set in the backing field by the setter.
Good job.
Jan Oberreiter
78,020 PointsI will start JS over again, not at the very beginning, but maybe at 4000 Points, because of this ... what's the point in having so many points, but I still you don' get too much, so I rather refresh the things ... thank you Steven ...