Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //USER CLICKS Scissors
- //------------------------------------------------------------
- $(document).ready(function() {
- $("#icon_scissors").click(function(){
- // Do your stuff here
- var userChoice = "Scissors";
- //Deciding computer choice
- var computerChoice = Math.random();
- if (computerChoice <0.34){
- computerChoice = "Rock";
- }else if(computerChoice <=0.67){
- computerChoice = "Paper";
- }
- else{
- computerChoice = "Scissors";
- }
- //Deciding winner
- switch(computerChoice) {
- case "Scissors":
- outcome= "Its a tie!";
- break;
- case "Rock":
- outcome= "You lost!";
- break;
- case "Paper":
- outcome="You won!";
- break;
- default:
- outcome = "Error - WinnerSelectionError";
- }//End of switch
- //Output to user
- console.log(outcome);
- $("#computerChoiceOutput").text(computerChoice)
- $("#outcomeOutput").text(outcome);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement