How to use the if statement in SetInterval

Alright, quickly following up on this. Thanks to the help of @russian-dima I’ve simplified the code and made it work :grin: I’ve kept it very minimal as the purpose of this code is very simple. For anyone interested here’s the code:

$w.onReady(function () {
    {
        setInterval(function () {
 let myMSB = $w("#statebox10").currentState.id
            console.log(myMSB)
 if ((myMSB) === "1") $w("#statebox10").changeState("2");

 else
                $w("#statebox10").changeState("1")
        }, 8000);
    }
});