Alternative to Rock Paper Scissors

Hello all,

I’m new to Codecademy and still learning but I found a way to alter the rock paper scissors project so that I can always win. Maybe since I’m so new I found this interesting. If anyone would like to try or see here is how I did it.

Maybe I’ll be humbled and someone will find a mistake I overlooked. Or maybe there is a more efficient way to do it.

If you think it’s interesting you can always try it also.

const randomNum = Math.floor(Math.random() * 3);

getComputerChoice = () => {

if (randomNum === 0) {
    return 'rock';
}
else if (randomNum === 1) {
    return 'paper';
}
else {
    return 'scissors';
}

}

const computerChoice = The computer chooses ${getComputerChoice()}.

console.log(computerChoice);

getUserChoice = () => {
if (randomNum === 0) {
return ‘paper’;
}
else if (randomNum === 1) {
return ‘scissors’;
}
else if (randomNum === 2) {
return ‘rock’;
}
}

const userChoice = The user chooses ${getUserChoice()}.

console.log(userChoice);

determineWinner = () => {
if (getComputerChoice() === ‘rock’ && getUserChoice() === ‘paper’) {
return ‘Paper beats rock.’;
}
else if (getComputerChoice() === ‘paper’ && getUserChoice() === ‘scissors’) {
return ‘Scissors beats paper.’;
}
else {
return ‘Rock beats scissors.’;
}
}

console.log(${determineWinner()} Looks like the user won!);

Hello @system5709777765! I found this quite interesting too. The only thing is that by using the “</>” button, you can make the code easier to read! Keep exploring these things, and I hope your coding journey is a good one! :wink: