Error with "Prevent Object Mutation" exercise

Hello,
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/prevent-object-mutation
One problem with this exercise. I put the right code but one error appeared.

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();

Do you agree ?

This code evaluate to error, the exercise its about to show that changing freezed objects properties throwing error., so when you try to assign a new value to freezed object property its obvious that it will throw an Error.

1 Like

ok, of course :slight_smile: thanks

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.