Toggle Class
toggleClass
that takes in two arguments:An HTML element
A string representing the class to toggle
The function should toggle the class on the element, adding it if it doesn't exist and removing it if it does.
Example usage:
// Given an HTML element <div class="my-class"></div>
const element = document.querySelector('.my-class');
toggleClass(element, 'active'); // <div class="my-class active"></div>
toggleClass(element, 'active'); // <div class="my-class"></div>