0

Game đŸ€”đŸ€” (something is wrong, computer always wins)

let gameOver = false; let computerChoices = ["rock", "paper", "scissors"]; function randomFrom(array) { return array[(Math.ceil(Math.random()*3)) ]; } function checkInput(input, computerChoices) { if (input === "quit") { return true; } let computerChoice = randomFrom(computerChoices); if(computerChoice === "rock" && input === "scissors"){ alert("Computer wins!"); return true; } else if (computerChoice === "scissors" && input === "paper"){ alert("Computer wins!"); return true; } else if (computerChoice === "paper" && input === "rock"){ alert("Computer wins!"); return true; } alert("Computer wins!");`` return false } function start(gameOver, computerChoices) { while (!gameOver){ let playerInput = ''; prompt("Hi! Enter rock/paper/scissors to play, or quit to stop playing."); gameOver = checkInput(playerInput, computerChoices); playerInput = "paper"; } } start(gameOver, computerChoices)

25th Oct 2018, 7:55 PM
Junie B.
4 RĂ©ponses
+ 3
where is the player win condition ? and draw condition ?
25th Oct 2018, 8:05 PM
Taste
Taste - avatar
+ 2
the code isn’t complete. computer is going to win by default as it doesn’t know how to lose so it’s just going to return the winning values from the if else statements.
25th Oct 2018, 8:16 PM
Eleanor
Eleanor - avatar
+ 1
Can you wrap your code up and publish it on Sololearn for better results of the help you need
25th Oct 2018, 8:42 PM
Femi
Femi - avatar
+ 1
i don't even see text that says player wins
26th Oct 2018, 6:05 AM
Jason Kennedy