Last active
August 29, 2015 14:05
-
-
Save Hollyw00d/0f8f8c87119761075565 to your computer and use it in GitHub Desktop.
Object Method Clarification Needed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From "Constructors with Methods" > 24/33 > Objects I > CodeAcademy.com | |
// QUESTIONS: | |
// 1. In line 19, why does the [rex] property, which is assigned to the [area] object, get a [calcArea] value? Or is it called a [calcArea] method of the [rex] property? | |
function Rectangle(height, width) { | |
this.height = height; | |
this.width = width; | |
this.calcArea = function() { | |
return this.height * this.width; | |
}; | |
// put our perimeter function here! | |
this.calcPerimeter = function() { | |
return this.height * 2 + this.width * 2; | |
}; | |
} | |
var rex = new Rectangle(7,3); | |
var area = rex.calcArea(); | |
var perimeter = rex.calcPerimeter(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment