I want to log the rolls but each time I run this code I get values each second (or as often as it is set at the interval). I want a way so that I can take log whenever the value changes, instead of getting it each second.
var red, black;
function mainOnRed() {
switch (checkMainOnRed()) {
case "red":
console.log("Black");
break;
case "black":
console.log("Red");
break;
}
};
function checkMainOnRed() {
if (currentColor == "black" && rowSet.length == 2) {
return "red";
} else {
return "black";
}
}
setInterval(mainOnRed, 1000);
Values:
currentColor
and
rowSet
are defined in other parts of the script.