I don’t understand why I didn’t pass this challenge, my code I quite correct

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function Bird() {
this.weight = 15;

this.getWeight = function(){
return weight;
};
}
  **Your browser information:**

User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 15_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Mobile/15E148 Safari/604.1

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

Link to the challenge:

You need to use let weight = 15; instead of this.weight = 15;. “this.” creates a variable for each individual object, but the variables would still be accessible publicly. let creates a variable that is limited in scope.

@mnl I really appreciate your help. I’ve fixed the problem. Thank you :blush:.

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