This is the code that I tried:
<script>
function random_Card() {
var colors = ["red", "yellow"];
var result = colors[Math.floor(Math.random() * colors.length)];
return result;
}
document.write(
'<div class="frontface" style=background-color:' + random_Card() + "></div>"
);
document.write(
'<div class="frontface" style=background-color:' + random_Card() + "></div>"
);
</script>
When the variable result
is returned it's not the same, for example if I executed random_Card()
two times I got 'red' and in the second execution I got 'yellow' but I want it to be the same no matter how many times I execute that function. Thanks.