Pls help me... I think i must put it in another place, no?

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function freezeObj() {
const MATH_CONSTANTS = {
  PI: 3.14
};
 Object.freeze(freezeObj);
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 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Challenge: Prevent Object Mutation

Link to the challenge:

Read the instructions very carefully:

" You need to freeze the MATH_CONSTANTS object"

What are you trying to freeze in your code?

Object.freeze(freezeObj);

1 Like

Now it tells me that: ReferenceError: Math_CONSTANTS is not defined

Done, finally … That’s the good code:

function freezeObj() {
  const MATH_CONSTANTS = {
    PI: 3.14
  };
  Object.freeze(MATH_CONSTANTS);
  try {
    MATH_CONSTANTS.PI = 99;
  } catch(ex) {
    console.log(ex);
  }
  return MATH_CONSTANTS.PI;
}
const PI = freezeObj();

But still thank you for help!

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