-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
22 lines (15 loc) · 994 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(function () {
// make array containing lists of classmates
var classMates = ['david h', 'sigge', 'eva', 'august', 'Åsa', 'lina', 'david l', 'katja', 'duygu', 'caglar', 'jakob', 'anders', 'arlind', 'bob', 'calle', 'dipak', 'douglas', 'emelie e', 'emelie s', 'emil', 'emilio', 'essi', 'fanny', 'gina', 'joakim', 'johan', 'mudassar', 'nayab', 'peter', 'quena', 'tim', 'tom', 'tony', 'ture', 'wei'];
var circle1 = document.getElementById('circle1');
circle1.addEventListener('click', pickMate);
var circle2 = document.getElementById('circle2');
circle2.addEventListener('click', pickMate);
var circle3 = document.getElementById('circle3');
circle3.addEventListener('click', pickMate);
/*randomly chooses classmate from list and then puts the name in the text field of circle element*/
function pickMate(event) {
var randomMate = classMates[Math.floor(Math.random()*classMates.length)];
event.target.firstElementChild.textContent = randomMate;
}
}());