forked from TheMoutonNoir/Hack22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
79 lines (59 loc) · 1.39 KB
/
main.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
67
68
69
70
71
72
73
74
75
76
77
78
79
const choice1Text = document.getElementById('choice1Text');
const choice2Text = document.getElementById('choice2Text');
const choice3Image = document.getElementById("choice1Image");
const choice1Value = document.getElementById('choice1Value');
const choice2Value = document.getElementById('choice2Value');
const choice2Image = document.getElementById("choice2Image");
//Data is: name, value, URL
const data = [
{
name: 'Riding a bike instead of driving',
value: 100,
},
{
name: 'Eating vegetables instead of meat',
value: 50,
},
{
name: 'A',
value: 2,
},
{
name: 'B',
value: 3,
},
{
name: 'C',
value: 5,
},
{
name: 'D',
value: 5,
},
{
name: 'E',
value: 6,
},
];
function startGame() {
id1 = randomIdFromData();
game += [id1];
id2 = randomIdFromData();
while (game.includes(id2)) {
id2 = randomIdFromData();
}
choice1Text.textContent = data[id1].name;
choice1Value.textContent = data[id1].value;
choice2Text.textContent = data[id2].name;
}
function pick(choiceNumber) {
revealChoice2();
}
function randomizeNext(id2){
}
function randomIdFromData() {
return Math.floor(Math.random() * data.length);
}
function revealChoice2() {
choice2Value.textContent = data[id2].value;
}