JavaScript · Junior · Question 70 of 75

What does el.classList.toggle("open") do?

Explanation

A second argument forces the state: toggle("open", isOpen). Using classList is safer than editing the className string by hand.

Further reading

Problem with a question

JavaScript · Junior · question 70

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz