Think of the toggle() method as the add() and remove() method together. It’ll either turn something on or off.

//lets say the body element had a class of 'blue' making it's background blue. There's also a button

const body = document.querySelector("body");
const classy = body.classList;
const btn = document.querySelector("button");

function change() {
  body.classList.toggle('blue');
}
//After adding the onclick attribute to the button whenever we click it it'll turn on and off the class making the body go from blue to default