There's a better way to add and remove classes and it's with a property called classList.

Press the buttons to try out different combinations and see it in action first.