Getting an error message and at the same time a successful submission too

I wrote the solution according to the given instruction but it is showing an error ([TypeError: Cannot assign to read only property ‘PI’ of object ‘#’])
but as I submitted it showed ‘correct solution’ with the error line still visible. why did this happen?

  **Your code so far**

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

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

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36.

Challenge: Prevent Object Mutation

Link to the challenge:

Right, it’s passing the unit tests but you are getting some JS errors. I assume that the JS errors are on purpose - they are coming because it is trying to change a frozen value - they are testing what you did.

got it!! thank you @kevinSmith :smile:

Just for further clarification, that’s why it’s in a try/catch block - to keep it from crashing for this error. The error message you are seeing in the console is from the console.log in the catch block.

thank you for your time and explanation @kevinSmith . Things got more clear to me. :star_struck: