I have 4 Button with class of active and now I wanna remove all of those class and then only add 1 class to the one I clicked on.
<button class="active btn">btn1</button>
<button class="active btn">btn2</button>
<button class="active btn">btn3</button>
<button class="active btn">btn4</button>
here is code I wrote so far:
let buttonOptions = document.querySelectorAll(".btn");
for (let i=0; i< buttonOptions.length; i++) {
    buttonOptions.addEventListener('click', function() {
        buttonOptions[i].classList.add("active");
    });   
}
but I don't know how should I remove those active class.
and also I wanna know there is a way to avoid using for specifically for removing class?




