-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
66 lines (44 loc) · 2.29 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// import functions and grab DOM elements
const shedButton = document.getElementById('shed-button');
const treeButton = document.getElementById('tree-button');
const boulderButton = document.getElementById('boulder-button');
const shedContainer = document.getElementById('shed-container');
const treeContainer = document.getElementById('tree-container');
const boulderContainer = document.getElementById('boulder-container');
const totalEl = document.getElementById('total');
const lossesEl = document.getElementById('losses');
const winsEl = document.getElementById('wins');
let correctGuesses = 0;
let totalGuesses = 0;
shedButton.addEventListener('click', () => {
// get a random item to call the 'correct spot'
// call the handleGuess function with the correct parameters (the user's guess and the "correct" hiding place) to do DOM work
});
treeButton.addEventListener('click', () => {
// get a random item to call the 'correct spot'
// call the handleGuess function with the correct parameters (the user's guess and the "correct" hiding place) to do DOM work
});
boulderButton.addEventListener('click', () => {
// get a random item to call the 'correct spot'
// call the handleGuess function with the correct parameters (the user's guess and the "correct" hiding place) to do DOM work
});
function getRandomHidingSpot() {
// initialize state
const hidingPlaces = [
'tree',
'shed',
'boulder'
];
const index = Math.floor(Math.random() * hidingPlaces.length);
// use the random index above and the array of hidingPlaces to get a random hiding place string
// return that random hiding place string
}
function handleGuess(userGuess, correctSpot) {
// first, right after clicking, we need to remove the emoiji face from the previous hiding place that way we don't end up with more than one emoji face
// we can do that by removing the .face class from all containers
// then increment the guesses
// then use getElementById and the correctSpot string to grab the appropriate container from the DOM
// then add the .face css class to that element so that the face shows up
// then if the user guess is correct, increment the correct guesses
// update the DOM to show the new value of wins, losses and total guesses to the user
}