let el = document.getElementById('a');
function func(){
let timeId;
const handleScroll = () => {
let scrollPos = window.pageYOffset;
document.getElementById('z').innerHTML = scrollPos;
if(scrollPos > 600) {
if(!el.classList.contains('timer')) {
el.classList.add('timer');
let b = 60;
timeId = setInterval(() => {
b--;
el.innerHTML=b;
if(b == 0){
el.classList.remove('timer');
clearInterval(timeId);
alert('Отлично!');
}
}, 1000);
}
} else {
console.warn('stop');
clearInterval(timeId);
}
}
window.addEventListener('scroll', handleScroll);
}
func();
var myInterval = setInterval(function(){
//ваша функция
}, 1000);
function myStopFunction() {
clearInterval(myInterval );
}