classList toggle
classList.toggle
accepts a second boolean parameter to add or remove a class.
This technique saves an if statement.
// add/remove with if
if (checkbox.checked) {
document.body.classList.add('menu-open')
} else {
document.body.classList.remove('menu-open')
}
// toggle with 2nd parameter
document.body.classList.toggle('menu-open', checkbox.checked)
Thanks to the legendary David DeSandro for the trick.