Make Your Own Method


I can't solve what's wrong.
"Oops, try again. It looks like you have an error in your code. Here's the message: ReferenceError: 'setWidth' no está definido "

var rectangle = new Object();
rectangle.height = 3;
rectangle.width = 4;
// here is our method to set the height
rectangle.setHeight = function (newHeight) {
  this.height = newHeight;
// help by finishing this method
rectangle.setWidth = function (newWidth) {
    this.width = newWidth;
rectangle.width = setWidth;
rectangle.height = setHeight;
// here change the width to 8 and height to 6 using our new methods


could you explain this two lines:

rectangle.width = setWidth;
rectangle.height = setHeight;

why did you code it like this? Personally, i would remove them


is that the problem
..i remove them but it still wont run


its the problem in datasolver66743 code, doesn't mean its the same for you. Please go here and make a new topic if you have a question, otherwise we clutter this topic.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.