Area and Circumference of a Circle
Given radius
radius of a circle, write a JS constructor function with the methods getArea and getCircumference to calculate the area and circumference of the circle.
Note
The value of π = 3.14
Quick Tip
Use the formulae to calculate,
Sample Input 1
7
Sample Output 1
153.86
43.96
Sample Input 2
25
Sample Output 2
1962.5
157
function GivenRadius(radius) {
this.radius = radius;
this.getArea = () => console.log(3.14 * radius ** 2);
this.getCircumference = () => console.log(2 * 3.14 * radius);
this.getArea();
this.getCircumference();
}
const rad = new GivenRadius(7);
const circle = new GivenRadius(25);
Comments
Leave a comment