While Writing code in JavaScript i got this error: Cannot read properties of undefined

While Writing code in JavaScript i got this error: Cannot read properties of undefined (reading ‘ className’ ) and the line of error is currentBtn[0]. className = currentBtn [0].className.replace (‘ active-btn’, ‘ ‘);

I’m Expecting page Transition effect like changing colors whenever i click the button.