You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prevent Object Mutation with Object.freeze: Conflicting info #43330
help wantedOpen for all. You do not need permission to work on these.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.
At the top, the challenge says, " Any attempt at changing the object will be rejected without an error." A few lines later it says, "The obj.review and obj.newProp assignments will result in errors".
This seems to be conflicting information - will there be an error or not? Maybe the 2nd part should say "The obj.review and obj.newProp assignments will be rejected".
I do agree that some clarification here would be beneficial.
Possibly changing that first line to `Any attempt at changing the object will be rejected, with an error thrown if the script is running in strict mode.
And the second line being The obj.review and obj.newProp assignments will result in errors, because our editor runs in strict mode by default, and the console will...
help wantedOpen for all. You do not need permission to work on these.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.
Activity
amberream commentedon Aug 28, 2021
Oddly, when I run the tests I can see an error in the log:
[TypeError: Cannot assign to read only property 'PI' of object '#']
But when I run the same code in jsFiddle there is no error in the console.
Update: When I add "use strict" in jsFiddle I get an error. This challenge should definitely mention that you only get an error in strict mode!
One of the previous challenges about "let" and "const" mention strict mode briefly, but it might be good to explain strict mode more. This page was helpful: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode
naomi-lgbt commentedon Sep 1, 2021
I do agree that some clarification here would be beneficial.
Possibly changing that first line to `Any attempt at changing the object will be rejected, with an error thrown if the script is running in strict mode.
And the second line being
The obj.review and obj.newProp assignments will result in errors, because our editor runs in strict mode by default, and the console will...Thoughts?
Sembauke commentedon Sep 5, 2021
That seems like a good solution Nich, I'll put a help wanted label on it!