Constructors and Methods- JavaScript

Hi, I’m having some problems with the following code it keeps telling me that there is something wrong with my syntax but I just don’t know what or where to look!

function Rectangle(height, width) {
  this.height = height;
  this.width = width;
  this.calcArea = function() {
      return this.height * this.width;
  this.calcPerimeter=function() {
     return 2*this.height + this.width*2

var rex = new Rectangle(7,3);
var area = rex.calcArea();
var perimeter = rex.calcPerimeter();

There’s a closing curly bracket missing in line 5… I’d suggest to run your scripts in a browser console (or maybe node) to get some more useful feedback. ;-)

Could you show me, please?

AFAIK for most browsers it’s a simple matter of pressing the f12 key and clicking the console tab on web dev. You may need to reload the page to see the console errors.

Does that work for you? If not, what browser are you using?

Legend, thanks!!!:slight_smile:

Hi, littlebird, I use Codeacademy and the editor they use can be found here;

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