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: