33/33 - How test?


#1

My code is ok, but if I wanted to test the functions, how would I do it?

function Circle (radius) {
this.radius = radius;
this.area = function () {
return Math.PI * this.radius * this.radius;

};
// define a perimeter method here
this.perimeter = function () {
    return 2 * Math.PI * this.radius;
}

};

Let's say I wanted pass the number 10 to both the area and the perimeter function and then console.log the results. Does anyone know how to do that?

I am pretty sure it involves assigning some variables. Thanks!


#2

Your object Circle has only one parameter (radius) and it is using that to calculate the area and perimeter. So assigning 10 to both the area and the perimeter is not possible with your current object.


#3

Why don't try this :grinning:

function Circle (radius) {
    this.radius = radius;
    this.area = function () {
        return Math.PI * this.radius * this.radius;
        
    };
    // define a perimeter method here
    this.perimeter = function () {
        return 2* Math.PI * this.radius;
    }
};