Skip to content

Commit

Permalink
added some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
brandond98 committed Nov 14, 2020
1 parent 57acc54 commit b0817ba
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ document.querySelector('.number').textContent = secretNumber;
document.querySelector('.check').addEventListener('click', function () {
const guess = Number(document.querySelector('.guess').value);

// When there is no input
if (!guess) {
document.querySelector('.message').textContent =
'You need to enter a number! 😄';

// When the player wins
} else if (guess === secretNumber) {
document.querySelector('.message').textContent =
'You entered the correct number! 🎉';

// When the guess it too high
} else if (guess > secretNumber) {
if (score > 1) {
document.querySelector('.message').textContent = 'Too high, try again!';
Expand All @@ -22,6 +27,8 @@ document.querySelector('.check').addEventListener('click', function () {
document.querySelector('.message').textContent = 'You lost the game!';
document.querySelector('.score').textContent = '0';
}

// When the guess it too low
} else if (guess < secretNumber) {
if (score > 1) {
document.querySelector('.message').textContent = 'Too low, try again!';
Expand Down

0 comments on commit b0817ba

Please sign in to comment.