I created two different websites. One is a simple dice rolling game and the other is supposed to play drum sounds when different buttons are selected. I can't seem to get either to run successfully on github even though they both work when I use the local files. The common thread between the two is that they both use javascript.
I saw some questions from before when people had similar problems so I checked to make sure I was using the close tag with my script: . And I tried to make sure that there was no mixed content (like http vs https in some places). I don't know what it is I'm missing, but any insight would be greatly appreciated!
https://mobolanleadebesin.github.io/Dice-Game/
https://github.com/MobolanleAdebesin/Dice-Game
// Player 1
var randomNumber1 = ((Math.random()) * 6) + 1;
randomNumber1 = (Math.floor(randomNumber1));
if(randomNumber1 == 1) {
document.querySelectorAll("img") [0].setAttribute("src", "images/dice1.png");
}
else if (randomNumber1 == 1){
document.querySelectorAll("img") [0].setAttribute("src", "images/dice2.png");
}
else if(randomNumber1 == 3){
document.querySelectorAll("img") [0].setAttribute("src", "images/dice3.png");
}
else if(randomNumber1 == 4){
document.querySelectorAll("img") [0].setAttribute("src", "images/dice4.png");
}
else if(randomNumber1 == 5){
document.querySelectorAll("img") [0].setAttribute("src", "images/dice5.png");
}
else if(randomNumber1 == 6){
document.querySelectorAll("img") [0].setAttribute("src", "images/dice6.png");
}
// Player 2
var randomNumber2 = ((Math.random()) * 6) + 1;
randomNumber2 = (Math.floor(randomNumber2));
if(randomNumber2 == 1) {
document.querySelectorAll("img") [1].setAttribute("src", "images/dice1.png");
}
else if (randomNumber2 == 1){
document.querySelectorAll("img") [1].setAttribute("src", "images/dice2.png");
}
else if(randomNumber2 == 3){
document.querySelectorAll("img") [1].setAttribute("src", "images/dice3.png");
}
else if(randomNumber2 == 4){
document.querySelectorAll("img") [1].setAttribute("src", "images/dice4.png");
}
else if(randomNumber2 == 5){
document.querySelectorAll("img") [1].setAttribute("src", "images/dice5.png");
}
else if(randomNumber2 == 6){
document.querySelectorAll("img") [1].setAttribute("src", "images/dice6.png");
}
// Heading
if( randomNumber1 > randomNumber2){
document.querySelector("h1").textContent = "Player 1 Wins!";
}
else if (randomNumber1 < randomNumber2){
document.querySelector("h1").textContent = "Player 2 Wins!";
}
else if (randomNumber1 == randomNumber2){
document.querySelector("h1").textContent = "Its a tie!";
}
© 2019 GitHub, Inc.
Terms
Privacy
Security
Status
Help
Contact GitHub
Pricing
API
Training
Blog
About
.container {
width: 70%;
margin: auto;
text-align: center;
}
.dice {
text-align: center;
display: inline-block;
}
body {
background-color: #393E46;
}
h1 {
margin: 30px;
font-family: 'Lobster', cursive;
text-shadow: 5px 0 #232931;
font-size: 8rem;
color: #4ECCA3;
}
p {
font-size: 2rem;
color: #4ECCA3;
font-family: 'Indie Flower', cursive;
}
img {
width: 80%;
}
footer {
margin-top: 5%;
color: #EEEEEE;
text-align: center;
font-family: 'Indie Flower', cursive;
}
© 2019 GitHub, Inc.
Terms
Privacy
Security
Status
Help
Contact GitHub
Pricing
API
Training
Blog
About
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Dicee</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Indie+Flower|Lobster" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>Refresh Me</h1>
<div class="dice">
<p>Player 1</p>
<img src="images/dice6.png">
</div>
<div class="dice">
<p>Player 2</p>
<img src="images/dice6.png">
</div>
</div>
<script src="index.js" charset="utf-8"></script>
</body>
<footer>
www App Brewery com
</footer>
</html>