I want to generate a random number and link that random generated number to a word. I'm using if-statement to do this, but I just can't seem to get it working.
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<p id="alpha"></p>
<p id="beta"></p>
<script>
function myFunction() {
var merc;
var random = Math.floor(Math.random() * 23);
if (random == 0) {
merc = "Guardian";
} else {
merc= "rest";
}
document.getElementById("beta").innerHTML = merc;
}
</script>
</body
</html>
Aucun commentaire:
Enregistrer un commentaire