Skip to content

Instantly share code, notes, and snippets.

@stevencombs
Created September 21, 2013 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencombs/6652976 to your computer and use it in GitHub Desktop.
Save stevencombs/6652976 to your computer and use it in GitHub Desktop.
// Javascript Getting Started with Programming
// A Codecademy Javascript (Make Your Own Method) assignment
// Dr. Steven B. Combs, coding novice
var rectangle = new Object(); // New object 'rectangle'
rectangle.height = 3; // Rectangle height 3
rectangle.width = 4; // Rectangle width 4
rectangle.setHeight = function (newHeight) { // Set rectangle height function
this.height = newHeight; // Use 'this' as placeholder to modify object called
};
rectangle.setWidth = function (newWidth) { // Set rectangel width function
this.width = newWidth; // Use 'this as placeholder to modify object called
};
rectangle.setHeight (6); // Change rectangle height 6
rectangle.setWidth (8); // Change rectangle width 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment