Game Rock, Paper and Scissor

var userChoice = prompt("Do you choose rock, paper or scissors?"); console.log("User: " + userChoice); var computerChoice = Math.random(); if (computerChoice < 0.34) { computerChoice = "rock"; } else if(computerChoice <= 0.67) { computerChoice = "paper"; } else { computerChoice = "scissors"; } console.log("Computer: " + computerChoice); var compare = function(computerChoice, userChoice) { if(computerChoice === userChoice){ return "The result is a tie!"; } else if(computerChoice === "rock") { if(userChoice === "scissors") { return "rock wins"; } else { return "paper wins"; } } else if(computerChoice === "paper") { if(userChoice === "rock"){ return "paper wins"; } else { return "scissors wins"; } } else if(computerChoice === "scissors") { if(userChoice === "rock"){ return "rock wins"; } else { return "scissors wins"; } } }; console.log(compare(computerChoice, userChoice));
this is a code of game "suit", the name of "suit" is always they say for indonesian, and it is i will try to create this game for digital...

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.