Object.freeze() method explanation

I have used the Object.freeze() for the function freezeObj() but still the value of PI changes.
Anyone, please help me with this scenario.


function freezeObj() {
const MATH_CONSTANTS = {
  PI: 3.14
};
// Only change code below this line
Object.freeze(freezeObj);


// Only change code above this line
try {
  MATH_CONSTANTS.PI = 99;
} catch(ex) {
  console.log(ex);
}
return MATH_CONSTANTS.PI;
}
const PI = freezeObj();

Challenge: Prevent Object Mutation

Link to the challenge:

You are trying to freeze the function freezeObj(), not the MATH_CONSTANTS object

2 Likes