I receive an error telling me MATH_CONSTANTS is read-only, but I seem to be doing what the proposed solution is telling me to do.
Your code so far
function freezeObj() {
'use strict';
const MATH_CONSTANTS = {
PI: 3.14
};
// Only change code below this line
Object.freeze(MATH_CONSTANTS);
MATH_CONSTANTS = 3.24;
console.log(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/86.0.4240.111 Safari/537.36
.
Challenge: Prevent Object Mutation
Link to the challenge: