33/33 Methods question


#1



The below code logs:

5
[Function]
[Function]

Why doesn't this log the following?

5
some number for the area
some number for the perimeter

Thanks!


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;    
    };
};

circle1 = new Circle(5);

console.log(circle1.radius);
console.log(circle1.area);
console.log(circle1.perimeter);


#2

recall the lesson 16 (or so)
if you call a function without () you get the function description,
compared to call a function with () you get the result (the function running).

so replace:
console.log(circle1.area);
console.log(circle1.perimeter);

with:
console.log(circle1.area());
console.log(circle1.perimeter());

radius is a property
area is a function
perimeter is a function


#3

Thanks! :smile: I knew I must've been forgetting something simple.


#4