33/33


#1

var x = prompt("What is the radius of your circle?", "")
var y = new Circle(x)

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 Math.PI * this.radius * 2;
}

};

console.log("The area of your circle is " + y.area + ". The circumference of you circle is " + y.perimeter)

I know that this is not required for the activity but I was just wondering how you could print out the area and perimeter of a user inputted circle?


#2

Nice Job !

Very interesting, I've been looked for how just print the results of area and perimeter and you add the source of imputing data by users!

Well done!

We only need a way to solve the equations:

output:

The area of your circle is function () {
return (Math.PI * this.radius * this.radius);

}. The circumference of you circle is function () {
return (Math.PI * this.radius * 2);
}


#3

Thanks @marcelvip ! Yeah that is what I have been trying to do but it still doesn't give the answer in the output. A simpler way could of course be to remove the "this" from "this.area" with y.


#4

I had the same problem!

You've probably figured it out by now, but all you need is to include the () after the .area and .perimeter.

console.log("The area of your circle is " + y.area() + ". The circumference of you circle is " + y.perimeter())