-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path06decisionmaker.js
More file actions
25 lines (21 loc) · 1001 Bytes
/
06decisionmaker.js
File metadata and controls
25 lines (21 loc) · 1001 Bytes
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
arrt = ["It is certain", "It is decidedly so", "Without a doubt", "Yes, definitely", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Signs point to yes", "Yes", "Reply hazy, try again", "Ask again later", "Better not tell you now", "Cannot predict now", "Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no", "Outlook not so good", "Very doubtful"];
var arr = 6;
//roll a dice with arr sides
var roll = function (listofwords) {
//why are we no longer adding the one?
dice = Math.floor(Math.random()*listofwords.length);
//return the word at position ...
return(listofwords[dice]);
};
//Instead of calling almost the same line 6 times, loop it and recreate it
for (i=0; i<arr; i++){
if (i == arr-1){
document.write('<div id="divnum'+ i +'">' + roll(arrt) + '!</div>');
}
else if (i == 2){
document.write('<div id="divnum'+ i +'">Coder Dojo</div>');
}
else {
document.write('<div id="divnum'+ i +'"> </div>');
}
};