I have a website and I want to split adblocks to test and see which is generating me more money. And I have a code that works by crating a random whole number integer between 1 and 2 and depending on the selection, it will determine which script to run by using an if statement.
However, I want to know if there's an actual JavaScript function that would not choose the numbers at random but rather alternate going back and forth. Let me know.
This is the current script which works at random.
<script type="text/javascript">
test = Math.floor(Math.random() * 2) + 1;
if (test == 1){
document.write("we got number 1");
}
else if (test == 2){
document.write("we got number 2");
}
else {
document.write("we got nothing");
}
</script>
Aucun commentaire:
Enregistrer un commentaire