Object.freeze() scope question

My understanding is that the Object.freeze(MATH_CONSTANTS) method recognizes a variable that’s not within the global scope. Is this made possible by the keyword Object?

I think this is pretty simple but it I wanna clear up what seems to me right now like an inconsistency.

Thanks in advance!

  **Your code so far**
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();
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: ES6 - Prevent Object Mutation

Link to the challenge:

This is all in the same scope, none of this is in the global scope

I get it. I thought I had looked over this so many times but still missed a bracket. For anyone as unfortunately blind as me reading in the future, the function end bracket is all the way at the second line from the bottom, meaning this is all in a local scope. woops

Also, formatting your code can help you see things like this as well, for example:

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;
}

If you press the F1 key while keyboard focus is in the editor and then type “format” you should see the “Format Document” command and it should tell you the keyboard shortcut to use.