I'm trying to store two random numbers between 0 and 10, in two different variables play1 and play2.
The maximum value for play2 will be 10 minus play1 value, ie, if play1 gets 6, maximum value for play2 will be 4.
how can I trigger play2 to store the second value? I need it to be triggered with a second click.
var min = 0;
var max = 10;
var play1;
var play2;
function myFunction() {
play1 = Math.floor(Math.random() * (max - min + 1)) + min;
max = 10 - play1
document.getElementById("result").innerHTML = play1;
if (play1 < 10 ) {
//trigger play2
}
}
<button onclick="myFunction()">Click me</button>
<p id="result"></p>
play2 = Math.floor(Math.random() * (max - min + 1)) + min;is it not?