Mutability 12 exercises
Problem

Comparing Object.freeze with as const

In our continued exploration of button types, we now have a modified version of ButtonAttributes that accepts cancel and confirm buttons. Each of these buttons exists as an object with a type of ButtonType. As in the previous exercises, the ButtonType remains either button, submit,

Loading exercise

Transcript

00:00 We've got a similar setup to what we had in our previous exercise. We're still on with the button type and we have some modified buttons. Now, modified buttons, it's got a slightly modified version of button attributes. So button attributes, this is apparently the way I'm saying it now, takes in two buttons.

00:16 It takes in cancel and confirm, both of which are objects with type button type. And button type is still button or submit or reset. Now, button attributes down here, we're doing an object.freeze on them. And object.freeze basically just freezes the object, essentially,

00:35 and says, okay, you can't modify properties on this. So your job is to work out why this is erroring. Because as we've seen with as const, surely this would just work, right? So your job is to diagnose the error, try to find an alternative way of doing this. And the code you can change is this button attributes set here. Good luck.