Working in the ES6 exercise on the Object.freeze() function. All code is correct but the console is returning a TypeError as follows:
TypeError: Cannot assign to read only property 'PI' of object '#<Object>'
For reference, this is my code
function freezeObj() {
"use strict";
const MATH_CONSTANTS = {
PI: 3.14
};
// change code below this line
Object.freeze(MATH_CONSTANTS);
// change code above this line
try {
MATH_CONSTANTS.PI = 99;
} catch( ex ) {
console.log(ex);
}
return MATH_CONSTANTS.PI;
}
const PI = freezeObj();
Browser Info:
Google Chrome Version 71.0.3578.98 (Official Build) (64-bit) on Mac OS 10.14.1