How to do such a test question?

create a window.counter = 1; on buttonClick let it count ++;
use

if(window.counter<15){
goto scene redPage;
}

and so on…
there´s also an example from @Daniel: