Freecodecamp ES6 challenge

Tell us what’s happening:
has anyone noticed you still get an error if you even solve the solution to the challenge correctly? is it a freecodecamp bug or there is something wrong with my solution. i cant progress to the next lesson because of this bug

Your code so far


function freezeObj() {
"use strict";
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();



// [TypeError: Cannot assign to read only property 'PI' of object '#<Object>']

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.

Challenge: Prevent Object Mutation

Link to the challenge:

That error is supposed to happen, remember this challenge is supposed to freeze an object, that means that object cannot be modified. At the bottom of the code, this is trying to modify the variable, but you froze it, so it made an error, that It cannot do that, because it’s frozen. If you actually press the Run The Test, it will pass.

try {
  MATH_CONSTANTS.PI = 99;
} catch (ex) {
  console.log(ex);
}
return MATH_CONSTANTS.PI;
}
1 Like

sure thank you very much… the error message freaked me out lol

1 Like