Facing some strange error in the challenge Use Closure to Protect Properties Within an Object from Being Modified Externally

Facing some strange error in the challenge Use Closure to Protect Properties Within an Object from Being Modified Externally
0

#1

Hi, Everyone. Constantly getting this error:

// running test
Maximum call stack size exceeded
// tests completed

Can anyone help?

Your code so far


function Bird() {
  let weight = 15;

  this.getWeight = function(){
    return weight;
  };
}
  let ducky = new Bird();
  ducky.getWeight();



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/use-closure-to-protect-properties-within-an-object-from-being-modified-externally/


#2

Hi,

You don’t need to include extra statements at bottom after defining your constructor. Also you don’t need a semicolon at the end of your getWeight function.