Skip to content

Commit 6474718

Browse files
committed
Fix max attempts to make sure it's at least 1 attempt
1 parent 61fe9c4 commit 6474718

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const game = () => {
1212
maxAttempts =
1313
modeButton.value === "attempts"
1414
? attemptsLimit
15-
: Math.max(Math.ceil(level * difficultyMultiplier)); //set max attempts based on level and difficulty
15+
: Math.max(Math.ceil(level * difficultyMultiplier), 1); //set max attempts based on level and difficulty
1616
guess = 0; //set initial guess value to 0
1717
maxGuess = 2 ** level; //set max guess value to 2 raised to level
1818
secret = randomInt(1, maxGuess); //set secret value to random integer between 1 and max guess value
@@ -61,7 +61,7 @@ const game = () => {
6161
maxAttempts =
6262
modeButton.value === "attempts"
6363
? attemptsLimit
64-
: Math.max(Math.ceil(level * difficultyMultiplier)); //set max attempts based on level and difficulty
64+
: Math.max(Math.ceil(level * difficultyMultiplier), 1); //set max attempts based on level and difficulty
6565
guess = 0;
6666
maxGuess = 2 ** level;
6767
secret = randomInt(1, maxGuess);
@@ -94,7 +94,7 @@ const game = () => {
9494
maxAttempts =
9595
modeButton.value === "attempts"
9696
? attemptsLimit
97-
: Math.max(Math.ceil(level * difficultyMultiplier)); //set max attempts based on level and difficulty
97+
: Math.max(Math.ceil(level * difficultyMultiplier), 1); //set max attempts based on level and difficulty
9898
maxGuess = 2 ** level; //increase max guess number by double
9999
secret = randomInt(1, maxGuess); //get random secret guess number
100100
maxText.textContent = maxGuess;

0 commit comments

Comments
 (0)