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

Edward's RPS project #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions real_code/hello.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#rock,#paper,#scissors {
height: 100px;
width: 100px;
border: 20px;
border-radius: 50px;
}
#rock {

}
#paper {

}
#scissors {

}
10 changes: 10 additions & 0 deletions real_code/hello.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<title>Rock,Paper,Scissors</title>
</head>
<body>

</body>
</html>
35 changes: 35 additions & 0 deletions real_code/hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
$(document).ready(function(){
var userChoice = prompt("Do you choose rock, paper or scissors?");
Copy link
Member

Choose a reason for hiding this comment

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

nice!

var computerChoice = Math.random();



if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
Copy link
Member

Choose a reason for hiding this comment

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

should be on a new line

var compare = function(choice1,choice2) {
if(userChoice === computerChoice) {
return "The result is a tie!";
};
if(choice2 === "scissors") {
return "scissors wins";
Copy link
Member

Choose a reason for hiding this comment

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

Whenever you return from a function, that means the code following it will never get executed 🐼

Copy link
Member

Choose a reason for hiding this comment

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

regardless, the code in this code block needs to be indented.

$('body').append("scissors wins");
}
else {
Copy link
Member

Choose a reason for hiding this comment

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

indent. make sure the rest of the function body is indented.

return "paper wins";
$('body').append("paper wins");
}
if(choice2 === "scissors") {
return "rock wins";
$('body').append("rock wins");
}
else {
return "scissors wins";
$("body").append("scissors wins");
}
};
});
Copy link
Member

Choose a reason for hiding this comment

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

overall this is definitely heading in the right direction 🎉. just make sure you keep your code neatly formatted to make it easier to read. For example, make sure to use indentation when appropriate (inside code blocks), and try to maintain an equal width of indentation (use the tab key on your keyboard instead of the spacebar)