Код для бесконечного цикла
function innf(){
Psy('pink','green',interval);
setTimeout(function(){
innf();
},0);
}
<html>
<head>
<script>
function inc(){
interval += 500;
if(document.getElementById('dec').disabled){
document.getElementById('dec').disabled = false;
}
}
function dec(){
interval -= 500;
if(interval < 0){
alert('error');
document.getElementById('dec').disabled = true;
}
}
var Psy = function(firstColor, SecondColor, interval,inf) {
bg.style.background = firstColor;
setTimeout(function() {
bg.style.background = SecondColor;
}, interval);
}
</script>
</head>
<body id="bg">
<button id="start" onclick="innf();">start</button>
<button id="stop" onclick="stopp();">stop</button>
<button onclick="inc();">+</button>
<button id="dec" onclick="dec();">-</button>
</body>
</html>