rissa146 Posted January 16, 2016 Share Posted January 16, 2016 Does anyone know the steps to 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. Link to comment Share on other sites More sharing options...
Ingolme Posted January 16, 2016 Share Posted January 16, 2016 This is a homework question, right? Do you know what a constructor function is? And a method? Link to comment Share on other sites More sharing options...
rissa146 Posted January 17, 2016 Author Share Posted January 17, 2016 I am looking for a tutorial that can help me navigate this new coding language as I have a hard time articulating what needs to be done. Link to comment Share on other sites More sharing options...
rissa146 Posted January 17, 2016 Author Share Posted January 17, 2016 That's why I asked for steps, not answers. Link to comment Share on other sites More sharing options...
rissa146 Posted January 17, 2016 Author Share Posted January 17, 2016 function myFunct(x,y){ this.x ; 100; this.y 100 return x *y; } // to call the function write MyFunct(5,2) Link to comment Share on other sites More sharing options...
Ingolme Posted January 17, 2016 Share Posted January 17, 2016 If you're taking a course then you probably should check some of your course material for the answer. If you're not taking a course then where did you find this problem? Your first answer would solve the constructor problem if the syntax was correct, but you have not created a method that returns the area. It would also be better to give a meaningful name to your object rather than "myFunct" Link to comment Share on other sites More sharing options...
davej Posted January 18, 2016 Share Posted January 18, 2016 Yes, I too am curious. Where are these questions coming from and what tutorials have you looked at? http://lmgtfy.com/?q=javascript+tutorial Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now