rissa146 Posted January 19, 2016 Share Posted January 19, 2016 Create a Shape constructor function that has a height and width property. Include a method that will calculate the area of the shape, where area is defined as the shape's height multiplied by its width.function shapeFunct(x,y){ this.height = x; this.width = y; return x * y;}// call the function shapeFunct(100,100); Link to comment Share on other sites More sharing options...
Ingolme Posted January 19, 2016 Share Posted January 19, 2016 That's not a constructor yet, that's a function. Do you know what a constructor is? And what a method is? You need to go back through your course material and read about constructors and methods. Here's the W3Schools page on the matter: http://www.w3schools.com/js/js_object_prototypes.asp However, I recommend you go back to learn the basics before attempting object-oriented programming. Even then, if you've never learned object-oriented programming before, Javascript is not the best language to learn it from. Javascript's version of "object-oriented" programming is very weird and does not match the actual theory of object-oriented programming. Link to comment Share on other sites More sharing options...
thescientist Posted January 19, 2016 Share Posted January 19, 2016 closing as this also a duplicate of the original thread here http://w3schools.invisionzone.com/index.php?showtopic=54673 Link to comment Share on other sites More sharing options...
Recommended Posts