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

6 bugs found and fixed #56

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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1>Guessing Game</h1>
Would you like to play again?
</p>
</div>
<button id="reset">Reset</button>
<input id="reset" type="reset" value="Reset">
</main>
<script src="index.js"></script>
</body>
Expand Down
18 changes: 9 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ function checkGuess() {
if (guess < targetNumber) {
tooLowMessage.style.display = '';
} else {
tooLowMessage.style.display = '';
tooHighMessage.style.display = ''; // (3)
}

const remainingAttempts = maxNumberOfAttempts - attempts;

numberOfGuessesMessage.style.display = '';
numberOfGuessesMessage.innerHTML = `You guessed ${guess}. <br> ${remainingAttempts} guesses remaining`;
}

if (attempts ==== maxNumberOfAttempts) {
//4= (2)
if (attempts === maxNumberOfAttempts) {
submitButton.disabled = true;
guessInput.disabled = true;
}
Expand All @@ -61,23 +61,23 @@ function checkGuess() {

resetButton.style.display = '';
}

// 6 = instead of <=
function hideAllMessages() {
for (let elementIndex = 0; elementIndex <= messages.length; elementIndex++) {
for (let elementIndex = 0; elementIndex < messages.length; elementIndex++) {
messages[elementIndex].style.display = 'none';
}
}

funtion setup() {
//funtion (1)
function setup() {
// Get random number
targetNumber = getRandomNumber(1, 100);
console.log(`target number: ${targetNumber}`);

// Reset number of attempts
maxNumberOfAttempts = 0;
attempts = 0; //attempts = 0;

// Enable the input and submit button
submitButton.disabeld = false;
submitButton.disabeled = false; //(5)
guessInput.disabled = false;

hideAllMessages();
Expand Down