I'm trying to create a random number generator. so far I have
<script>
var arr = []
while (arr.length < 4) {
var randomnum = Math.ceil(Math.random() * 10)
var found = false;
for (var i = 0; i < arr.length; i++) {
if (arr[i] == randomnum) {
found = true;
break
}
}
if (!found) arr[arr.length] = randomnum;
}
document.write(arr);
</script>
But instead of having the numbers display in line, i'd like to have it say "person a rolls __, Person b rolls __, etc" but I have no idea how to do that through javascript.
Also, how would I declare a winner, like "Person A Wins" (the winner being the highest roller)
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire