Hello everyone! This is my very fisrt post on a codecademy forum. I really liked how my project turned out so I am excited to share it with you all.
Please feel free to critique my work and comment on it. I’m looking forward to reading any type of comment.
console.log("Rock, Paper, Scisors Game");
// Select your choice
let playerChoice = ""
let compChoice = Math.floor(Math.random () * 4);
//Translate the computer's choice
switch (compChoice) {
case 1:
compChoice = "Rock";
break;
case 2:
compChoice = "Paper";
break;
case 3:
compChoice = "Scissor";
break;
}
if (compChoice != 0) {
console.log(game(compChoice, playerChoice));
console.log(`The computer chose ${compChoice}, you chosed ${playerChoice}.`);
} else {
console.log("The computer can't make a choice now. Try again.")
}
function game(compChoice, playerChoice) {
//its a draw
if (compChoice === playerChoice) {
return "It's a draw!";
}
//computer wins
if ("Rock", "Scissor" || "Paper","Rock" || "Scissor","Paper") {
return "The computer wins";
} else { //The player wins
return "You win!"
}
}