dimanche 3 mai 2020

Javascript Coin Flip Beginner

<script>

function myfunction () {
    var x = Math.random();

    if (x > 0.5) {
        document.write("Heads!");
    } else {
        document.write("Tails!");
    }
}

</script>

The following code is supposed to print either Heads! or Tails! as if a coin was being flipped. However, it does not seem to work.




Aucun commentaire:

Enregistrer un commentaire