Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

found 3 bugs, working on the 4th #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ <h1>Guessing Game</h1>
</p>
<div>
<input type="number" id="guess" min="1" max="99" />
<button id="submit">Submit Guess</button>
<button id="submit" style="display: '';">Submit Guess</button>
</div>
<div>
<p class="message" id="number-of-guesses"></p>
<p class="message" id="too-high">You guessed too high. Try again.</p>
<p class="message" id="too-low">You guessed too low. Try again.</p>
<p class="message" id="max-guesses">
<p class="message" id="number-of-guesses" style="display: '';"></p>
<p class="message" id="too-high" style="display: '';">You guessed too high. Try again.</p>
<p class="message" id="too-low" style="display: '';">You guessed too low. Try again.</p>
<p class="message" id="max-guesses" style="display: '';">
You reached the max number of guesses
</p>
<p class="message" id="correct">
<p class="message" id="correct" style="display: '';">
Congratulations, You guessed correctly! <br />
Would you like to play again?
</p>
</div>
<button id="reset">Reset</button>
<button id="reset" style="display: '';">Reset</button>
</main>
<script src="index.js"></script>
</body>
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const correctMessage = document.getElementById('correct');

let targetNumber;
let attempts = 0;
const maxNumberOfAttempts = 5;
let maxNumberOfAttempts = 5;

// Returns a random number from min (inclusive) to max (exclusive)
// Usage:
Expand Down Expand Up @@ -52,14 +52,14 @@ function checkGuess() {
numberOfGuessesMessage.innerHTML = `You guessed ${guess}. <br> ${remainingAttempts} guesses remaining`;
}

if (attempts ==== maxNumberOfAttempts) {
if (attempts === maxNumberOfAttempts) {
submitButton.disabled = true;
guessInput.disabled = true;
}

guessInput.value = '';

resetButton.style.display = '';
resetButton.style.display = 'none';
}

function hideAllMessages() {
Expand All @@ -68,7 +68,7 @@ function hideAllMessages() {
}
}

funtion setup() {
function setup() {
// Get random number
targetNumber = getRandomNumber(1, 100);
console.log(`target number: ${targetNumber}`);
Expand All @@ -77,7 +77,7 @@ funtion setup() {
maxNumberOfAttempts = 0;

// Enable the input and submit button
submitButton.disabeld = false;
submitButton.disabled = false;
guessInput.disabled = false;

hideAllMessages();
Expand Down