ES6: (Prevent Object Mutation)

Tell us what’s happening:

Hi,
please i need assistance i dont know what am doing wrong…

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

Your browser information:

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

Challenge: Prevent Object Mutation

Link to the challenge:

what’s wrong? it seems you did right

if you mean that you are getting an error, it comes from this

here a property of a freezed object is trying to be reassigned and this gives the error

but your code should pass the tests

:smile: thanks

omg, I feel so dumb rn. I was so focused on the error that I didn’t even bother to submit the answer. Thank you!

Hey @lascivit!
This topic is inactive for 5 months. If you have any doubt please create a new topic.

Thanks and Happy Coding!