Skip to content

Commit

Permalink
added hogh score functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
brandond98 committed Nov 14, 2020
1 parent 1db35bd commit 69e071d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

let secretNumber = Math.trunc(Math.random() * 20) + 1;
let score = 20;
let highScore = 0;

document.querySelector('.check').addEventListener('click', function () {
const guess = Number(document.querySelector('.guess').value);
Expand All @@ -20,6 +21,11 @@ document.querySelector('.check').addEventListener('click', function () {
document.querySelector('body').style.backgroundColor = '#60b347';
document.querySelector('.number').style.width = '30rem';

if (score > highScore) {
highScore = score;
document.querySelector('.highscore').textContent = score;
}

// When the guess it too high
} else if (guess > secretNumber) {
if (score > 1) {
Expand Down

0 comments on commit 69e071d

Please sign in to comment.