dimanche 28 février 2016

I don't know why my function Flip() in JavaScript isn't returning anything. I want it to return if it is heads or tails

JavaScript - I don't see anything obvious that is wrong

function Flip() {
    var Probability = Math.floor(Math.random());
    if (Probability > 0.5) {
        document.getElementById("message").innerHTML("Heads!");
    }
    if (Probability < 0.5) {
        document.getElementById("message").innerHTML("Tails!");
    }    

HTML - Nothing should be wrong in the HTML (besides selectors)

<body>
    <button onClick="Flip()" id="submit">FLIP THE COIN</button>
    <p id="message"></p>
</body>




Aucun commentaire:

Enregistrer un commentaire