Code on lesson 19


#1



https://www.codecademy.com/en/courses/spencer-sandbox/2/7?curriculum_id=506324b3a7dffd00020bf661#


Oops, try again. It looks like you have an error in your code. Here's the message: TypeError: square.calcPerimeter is not a function


var square = new Object();
square.sideLength = 6;
square.calcPerimeter = function() {
  return this.sideLength * 4;
};
// help us define an area method here
var square = new Object();
square.sideLength = 6;
square.calcArea = function() {
    return this.sidelength * this.sideLength;
};
var p = square.calcPerimeter();
var a = square.calcArea();


#2

@lodum,
You will have to integrate both Methods in the square object

var square = new Object();
square.sideLength = 6;
square.calcPerimeter = function() {
  return this.sideLength * 4;
};
square.calcArea = function() {
    return this.sidelength * this.sideLength;
};
console.log( square );
console.log( square.calcPerimeter.toString() );
console.log( square.calcArea.toString() );

#3

Thank you -- I would never have thought of merging.


#4

In the problem, what was the purpose of:
var p = square.calcPerimeter();
var a = square.calcArea();


#5

Never mind -- I got var p and var a!