Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Learning JavaScript
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MohammadAli Keshavarz
Learning JavaScript
Commits
a5ef0ece
Commit
a5ef0ece
authored
Oct 25, 2019
by
MohammadAli Keshavarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change picture of dice when click on roll dice
parent
6c5885b6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
app.js
section3/app.js
+15
-4
No files found.
section3/app.js
View file @
a5ef0ece
...
...
@@ -7,18 +7,29 @@ GAME RULES:
- The first player to reach 100 points on GLOBAL score wins the game
*/
var
scores
,
dice
,
roundScore
,
activePlayer
;
var
scores
,
roundScore
,
activePlayer
;
scores
=
[
0
,
0
];
roundScore
=
0
;
activePlayer
=
0
;
dice
=
Math
.
floor
(
Math
.
random
()
*
6
)
+
1
;
document
.
querySelector
(
"#current-"
+
activePlayer
).
textContent
=
dice
;
//
document.querySelector("#current-" + activePlayer).textContent = dice;
// document.querySelector("#current-" + activePlayer).innerHTML = "<h1>" + dice + "</h1>";
//-----------------------------------------------------------------
// var x = document.querySelector("#score-1").textContent;
// console.log(x);
document
.
querySelector
(
".dice"
).
style
.
display
=
"none"
;
document
.
querySelector
(
".dice"
).
style
.
display
=
"none"
;
document
.
querySelector
(
".btn-roll"
).
addEventListener
(
"click"
,
function
()
{
//create random number
var
dice
=
Math
.
floor
(
Math
.
random
()
*
6
)
+
1
;
// disply the result
var
diceDOM
=
document
.
querySelector
(
".dice"
);
diceDOM
.
style
.
display
=
"block"
;
diceDOM
.
src
=
"./dice-"
+
dice
+
".png"
;
// update current scores, if the rolled number was not one
if
(
dice
!==
1
)
{
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment