forked from itscodenation/dice-roll-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (23 loc) · 829 Bytes
/
script.js
File metadata and controls
23 lines (23 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$(document).ready(function(){
$("#roll-dice").click(rollDice());
function rolldice(){
var dice1 = Math.floor((Math.random()*6) +1);
var dice2 = Math.floor((Math.random()*6) +1);
switch(dice1){
case 1: $("#first").attr("src", "images/1");
case 2: $("#first").attr("src", "images/2");
case 3: $("#first").attr("src", "images/3");
case 4: $("#first").attr("src", "images/4");
case 5: $("#first").attr("src", "images/5");
case 6: $("#first").attr("src", "images/6");
}
switch(dice2){
case 1: $("#second").attr("src", "images/1");
case 2: $("#second").attr("src", "images/2");
case 3: $("#second").attr("src", "images/3");
case 4: $("#second").attr("src", "images/4");
case 5: $("#second").attr("src", "images/5");
case 6: $("#second").attr("src", "images/6");
}
};
});