added a simple score increasing function

This commit is contained in:
2025-08-28 10:16:31 -04:00
parent c8cd997d23
commit d857789455

View File

@@ -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] );