Skip to content

Instantly share code, notes, and snippets.

@acesaif
Last active April 19, 2017 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acesaif/05f44d170e9c60d197fd62a9c7665350 to your computer and use it in GitHub Desktop.
Save acesaif/05f44d170e9c60d197fd62a9c7665350 to your computer and use it in GitHub Desktop.
Rock Paper Scissors
<link href="https://fonts.googleapis.com/css?family=Macondo" rel="stylesheet">
<h1>ROCK - PAPER - SCISSORS</h1>
<h3> ... A Game by AceSaif ... </h3>
<h4>This game is completely powered by JavaScript which is a powerful Web Application Language.</h4>
<h4>Ergo I present this game as a tribute to every lad who plays this ...</h4>
<h5> ... Thank You ... </h5>
alert("This Game is Rock - Paper - Scissors");
alert("Give 'Rock / Paper / Scissors' as Your Choice");
var userChoice = prompt("Rock or Paper or Scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "Rock";
} else if (computerChoice <= 0.67) {
computerChoice = "Paper";
} else {
computerChoice = "Scissors";
}
alert("Computer's Choice: " + computerChoice);
function compare(choice1, choice2) {
if (choice1 === choice2) {
return alert("...The Result is a Tie!...");
}
else if (choice1 === "Rock") {
if (choice2 === "Scissors") {
return alert("Rock Wins... You Win...");
} else {
return alert("Paper Wins... Computer Wins...");
}
}
else if (choice1 === "Paper") {
if (choice2 === "Rock") {
return alert("Paper Wins... You Win...");
} else {
return alert("Scissors Wins... Computer Wins...");
}
}
else if (choice1 === "Scissors") {
if (choice2 === "Paper") {
return alert("Scissors Wins... You Win...");
} else {
return alert("Rock Wins... Computer Wins...");
}
}
else {
alert("Please give Authenticate Input!");
}
}
compare(userChoice, computerChoice);
var gameAgain = prompt("Want to Play Again?... Say - Yes / No -");
if (gameAgain === "Yes") {
alert("Then Hit Refresh Button");
} else if (gameAgain === "No") {
alert("... Do Your HomeWork ...");
} else {
alert("Help Yourself!!!");
}
body {
background-color: green;
}
h1, h3, h4, h5 {
font-family: Macondo, cursive;
text-align: center;
}
h1 {
font-size: 100px;
}
h3 {
font-size: 50px;
font-style: italic;
}
h4 {
font-size: 25px;
}
h5 {
font-size: 35px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment