Objects in review:Methods



I can't seem to figure out this exercise. It keeps mentioning this error message:
Oops, try again. Your code caused a TypeError when trying to call .perimeter(). Make sure you have properly defined the perimeter method. Use the .area() method as a guide. Here's the error message: TypeError: c.perimeter is not a function

Replace this line with your code. 

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


That is a function, not a method. so will raise an error.

this.perimeter: function() {
    return 2 * Math.PI * this.radius


thanks for helping. it worked fine now


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.