2025-08-28 10:16:31 -04:00
|
|
|
// array of words to be displayed randomly
|
2025-08-27 12:09:24 -04:00
|
|
|
const words = [
|
|
|
|
'red',
|
|
|
|
'car',
|
2025-08-28 10:06:38 -04:00
|
|
|
'bed',
|
|
|
|
'hat',
|
|
|
|
'cat',
|
|
|
|
'mat',
|
|
|
|
'pet',
|
|
|
|
'bin',
|
|
|
|
'run',
|
|
|
|
'bun'
|
2025-08-27 12:09:24 -04:00
|
|
|
];
|
|
|
|
|
2025-08-28 10:16:31 -04:00
|
|
|
// 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();
|
|
|
|
});
|
|
|
|
|
2025-08-28 10:06:38 -04:00
|
|
|
console.log( words[2] );
|