Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added customized player names #71

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ function newGame() {
score1.textContent = '0';
current0.textContent = '0';
current1.textContent = '0';
var r = confirm("Would you like to change the name of players?");
if (r == true) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how variables should declare.

var person = prompt("Please enter your name", player0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ' ' here

document.getElementById("name-0").innerHTML =person;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ' ' here

var person2 = prompt("Please enter your name", player1);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ' ' here

document.getElementById("name-1").innerHTML =person2;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ' ' here too

}
document.querySelector('.player-0-panel').classList.add('active');
document.querySelector('.player-1-panel').classList.remove('active');
document.querySelector('.dice').style.display = 'none'
Expand Down
11 changes: 10 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<div class="player-current-score" id="current-0">0</div>
</div>
</div>

<div class="player-1-panel">
<div class="player-name" id="name-1">Player 2</div>
<div class="player-score" id="score-1">0</div>
Expand All @@ -76,4 +75,14 @@
<script src="app.js"></script>
<!-- body ends here -->
</body>
<script>
var player0 = prompt("Please enter your name", "Player 1");
if (player0 != null) {
document.getElementById("name-0").innerHTML =player0;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not properly indented.

var player1 = prompt("Please enter your name", "Player 2");
if (player1 != null) {
document.getElementById("name-1").innerHTML =player1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not properly indented too.

}
</script>
</html>