Objective

Redefine the className property of the Element interface, manually in JavaScript.

Difficulty

Easy

Description

The className property, as we learnt about it in the chapter HTML DOM — Attributes, is defined on the Element interface. It is an accessor property meant to mirror the class attribute on the underlying element node.

That is, when the className property is retrieved, the underlying element's class attribute's value is retrieved. Similarly, when a value is set on the className property, it's set on the class attribute of the element node.

In this exercise, you have to redefine className manually in JavaScript.

In your implementation, className must continue to be an accessor property that could be get and set, performing the desired actions as mentioned above.