Code on lesson 19


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/spencer-sandbox/2/7?curriculum_id=506324b3a7dffd00020bf661#

<In what way does your code behave incorrectly? Include ALL error messages.>
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();

<do not remove the three backticks above>

#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!