force while loop to wait for settimeout

$w.onReady(function () {
    let n = 0;

    do {
        setTimeout(() => $w('#z').changeState('State3'), 2000);
        setTimeout(() => $w('#z').changeState('State4'), 4000);
        n++

    } while (n > 3);
});

the changestate code lines only execute once because while doesn’t wait for timeout

I read answers but I couldn’t write it properly, im using wix