Please need help on this challenge!

I have done this previous challenge, But after the running the code result show.
“[TypeError: Cannot assign to read only property ‘PI’ of object ‘#’]”

  **Your code so far**

function freezeObj() {
  PI: 3.14
// Only change code below this line


// Only change code above this line
try {
} catch(ex) {
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/98.0.4758.102 Safari/537.36

Challenge: Prevent Object Mutation

Link to the challenge:

Did the tests pass? You should prevent the changing of the frozen values.

No the test didn’t pass, Out of the 4 marks giving in the challenge , 3 marked and remaining one didn’t.

What is the failing test?

In this challenge i was ask to use Object.freeze to prevent mathematical constants from changing. You need to freeze the MATH_CONSTANTS object so that no one is able to alter the value of PI , add, or delete properties.

I know what the challenge is… I want to know which test you are failing. I can read the instructions. Copying the instructions into your post doesn’t really help.

There are 4 tests. Which one has the x?

the last one has the x , But now the all marks good. But where the text display shows this: “which i guest its not a succesfully done”

// running tests
// tests completed
// console output
[TypeError: Cannot assign to read only property ‘PI’ of object ‘#’]
[TypeError: Cannot assign to read only property ‘PI’ of object ‘#’]

If you have no X, then all tests passed. Looking at your code, it looked fine to me which is why I wanted to know what test was failing.

This right here says, "try to change the value of PI but catch and print out the error if you can’t", so you should see a message.

1 Like

Ok thanks thanks for your help.

1 Like

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