How to toggle class of element in JavaScript

DOM
Last updated Sep 22, 2018
<div id="box" class="highlighted"></div>
const element = document.querySelector("#box");

element.classList.toggle("highlighted");