Files
trinkets/wally/app.js

30 lines
623 B
JavaScript

// array of words to be displayed randomly
const words = [
'red',
'car',
'bed',
'hat',
'cat',
'mat',
'pet',
'bin',
'run',
'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] );