Introduction to Objects I help me please


#1

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

};
var square = new Object();

square.sideLength = 6;

square.calcPerimeter = function(){
console.log(this.sideLength * 4);
};

square.calcArea = function(){
console.log(this.sideLength * this.sideLength);
};

square.calcPerimeter();
square.calcArea();

};

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: Object doesn't support property or method 'perimeter'

please help me find out what I did wrong


#2

I think this might work

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

};
var square = new Object();
square.sideLength = 6;

square.calcPerimeter = function(){
console.log(this.sideLength * this.sideLength * 4);
};

square.calcArea = function(x, y) {
console.log(this.sideLength * this.sideLength);
};

square.calcPerimeter();
square.calcArea();

};

your code looks fine you just forgot to put another this.sideLength


#3

SyntaxError: Expected ';'


#4

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: Object doesn't support property or method 'perimeter'


#5

Does it say the same error?