From d85778945516ed0ade1db7fefc56eb286a052314 Mon Sep 17 00:00:00 2001 From: Mike Rockwell Date: Thu, 28 Aug 2025 10:16:31 -0400 Subject: [PATCH] added a simple score increasing function --- wally/app.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wally/app.js b/wally/app.js index d1dea74..599730b 100644 --- a/wally/app.js +++ b/wally/app.js @@ -1,3 +1,4 @@ +// array of words to be displayed randomly const words = [ 'red', 'car', @@ -11,4 +12,19 @@ const words = [ 'bun' ]; +// initial player score +let score = 0; + +// this function increases score variable by one, changes the score displayed, and prints it to the console +function increaseScore() { + score += 1; + document.querySelector('.player-score').innerHTML = `${score}`; + console.log(`score increased to ${score}`) +} + +// this is the click event that runs the increaseScore function +document.querySelector('.correct').addEventListener("click", () => { + increaseScore(); +}); + console.log( words[2] ); \ No newline at end of file