const button = document.querySelector('.reset');
button.addEventListener('click', () => {
document.querySelectorAll('.active').forEach(element => element.classList.remove('active'));
});
<div class="reset">сброс цвета</div>
заменить на <button type="button" class="reset">сброс цвета</button>
const list = document.querySelectorAll('.list .test')
window.addEventListener('click', (e)=> {
const target = e.target;
if(target.classList.contains('test')){
resetActiveItem()
target.classList.add('active')
}
if(target.classList.contains('reset')) {
resetActiveItem()
}
})
function resetActiveItem() {
list.forEach(item=>item.classList.remove('active'));
}