Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ROSHAMBO BITCHES!
//JavaScript-C24.2.0 (SpiderMonkey) var compare = function(choice1, choice2){ if (choice1 === "rock"){ if(choice2 === "scissors"){ return "rock wins"; }else if(choice2 === "rope"){ return "rope wins"; }else{ return "paper wins"; } }else if (choice1 === "paper"){ if(choice2 === "rock"){ return "paper wins"; }else if(choice2 === "rope"){ return "rope wins"; }else{ return "scissors wins"; } }else if (choice1 === "scissors"){ if(choice2 === "rock"){ return "rock wins"; }else if(choice2 === "rope"){ return "rope wins"; }else{ return "scissors wins"; } }else if (choice1 === "rope"){ if(choice2 === "rope"){ return "player rope wins"; }else{ return choice2+" wins"; } } else{ return "Invalid answer!"; } }; var tie = true; while (tie === true){ var userChoice = prompt("Do you choose rock, paper or scissors?"); var computerChoice = Math.floor(Math.random()*4); if (computerChoice === 0) { computerChoice = "rock"; } else if(computerChoice === 1) { computerChoice = "paper"; } else if(computerChoice === 2) { computerChoice = "scissors"; } else if(computerChoice === 3) { computerChoice = "rope"; } console.log("User: " + userChoice); console.log("Computer: " + computerChoice); if (userChoice === computerChoice && userChoice != "rope" && computerChoice != "rope"){ tie = true; prompt ("The result is a tie!"); }else{ tie = false; compare(userChoice, computerChoice); } }
run
|
edit
|
history
|
help
0
Logical NOT in JavaScript
An awkward iteration
Palindrome
Education-Salary
random3
David Anderson code challenge
Change format Numbers
fratrade
Set(), union, intersection, difference
Узнать значени синуса в радианах