Prevent Object Mutation: Overly Picky Correct Solution Criteria

Tell us what’s happening:
The final requirement isn’t cleared despite PI being 3.14. The default code is enough to show this via console logging.

The solution is to use “Object.freeze(MATH_CONSTANTS);” in the provided space, but doing something like “MATH_CONSTANTS = Object.freeze(MATH_CONSTANTS);” won’t work.

Your code so far


function freezeObj() {
  "use strict";
  const MATH_CONSTANTS = {
    PI: 3.14
  };
  // change code below this line
  MATH_CONSTANTS = 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();

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/prevent-object-mutation/

When you put MATH_CONSTANTS = Object.freeze(MATH_CONSTANTS); you’re freeze the MATH_CONSTANTS and trying to pass that to the const MATH_CONSTANTS this won’t work. You only need to freeze the MATH_CONSTANT , Object.freeze(MATH_CONSTANTS);, that way it’ll work fine.
Hope this help you.
You can read more about on: