added a simple score increasing function
This commit is contained in:
16
wally/app.js
16
wally/app.js
@@ -1,3 +1,4 @@
|
|||||||
|
// array of words to be displayed randomly
|
||||||
const words = [
|
const words = [
|
||||||
'red',
|
'red',
|
||||||
'car',
|
'car',
|
||||||
@@ -11,4 +12,19 @@ const words = [
|
|||||||
'bun'
|
'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] );
|
console.log( words[2] );
|
Reference in New Issue
Block a user