Use Closure to Protect Properties Within an Object from Being Modified Externally

Tell us what’s happening:
Hi, not sure what is wrong here. I tested on inspection and the get method is the correct output when i tested, a private variable and a getmethod yet my 2nd test is wrong
Your code so far

function Bird() {
  let weight = 10;

  this.getWeight = function(){
    return weight;


Your browser information:

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

Link to the challenge:

1 Like

Hi @Balancedsan,

Your code is right, but you should change the value of weight to 15 like this let weight = 15;

Hope this help you to solve example, good luck my friend.

Ali Mosaad

thank you very much it works :), weirdly it dosent state anywhere to change weight to 15


Hi @Balancedsan,

Good luck and have a happy coding, don’t miss small things again :wink:

Ali Mosaad