This is the code that diminish intervals between stages in the game Life.
document.getElementById("intervalMinus").addEventListener("click",function() {
var intervalToMinus = +document.getElementById("labelInterval").innerHTML - 100;
(intervalToMinus < 100) ? intervalToMinus += 90 : intervalToMinus;
(intervalToMinus <= 0) ? intervalToMinus == 10 : intervalToMinus;
document.getElementById("labelInterval").innerHTML = intervalToMinus;
changeInterval();
});
Obviosly when you tap the button it reduces the interval by 100, but if the interval is already less then 100, by 10.
(intervalToMinus > 0) ? intervalToMinus == 10 : intervalToMinus;
This part should guarantee that interval will never become negative. But it doesnt't work! I checked in chrome debugger, and saw, that JS just ignore this particular line.
intervalToMinus is equal to 0. Condition is true. Doesn't work. Why?