don't use the last number if it's the same
This commit is contained in:
parent
6c8ef3be9a
commit
bd7de49972
|
@ -47,6 +47,13 @@
|
||||||
const min = 1;
|
const min = 1;
|
||||||
const max = 12;
|
const max = 12;
|
||||||
const randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;
|
const randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setRandomNumber() {
|
||||||
|
const prevNumber = randomNumber;
|
||||||
|
while (prevNumber == randomNumber) {
|
||||||
|
generateRandomNumber();
|
||||||
|
}
|
||||||
randomNumberElement.textContent = randomNumber;
|
randomNumberElement.textContent = randomNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +69,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate an initial random number and countdown time
|
// Generate an initial random number and countdown time
|
||||||
generateRandomNumber();
|
setRandomNumber();
|
||||||
countdownTime = Math.floor(Math.random() * (30 - 10 + 1)) + 10; // Initial random countdown
|
countdownTime = Math.floor(Math.random() * (30 - 10 + 1)) + 10; // Initial random countdown
|
||||||
|
|
||||||
// Update countdown and refresh the number every second
|
// Update countdown and refresh the number every second
|
||||||
|
|
Loading…
Reference in New Issue