Rock Paper Scissors. I'm finally getting no errors, but it wont run? Please help

I’m not sure what I’m doing wrong. I’m not getting the player selection prompt to enter my option. Because of this the playRound function isn’t working

What should i change?


    function computerPlay(){

        const computerChoice = ["Rock", "Paper", "Scissors"]

        var random = Math.floor(Math.random()*3);

    let choice = computerChoice[random];


    return choice;


    function playerSelection(){

        let playerChoice = prompt('Shoot! Rock, paper or scissors. Type your choice!')

        const playerSelection = playerChoice.toUpperCase(0,1) + playerChoice.toLowerCase().slice(1);

       if (playerSelection != 'Rock' || 'Paper' || 'Scissors')

       {prompt('Oops! Please type your answer correctly. "Rock" "Paper" or "Scissors"')}

       return playerSelection


    function playRound(playerSelection,computerSelection){

        computerSelection = computerPlay();

        if ( (playerSelection == "Rock" && computerSelection =="Paper") || (playerSelection == "Paper" && computerSelection =="Scissors") || (playerSelection =="Scissors" && computerSelection =="Rock"))

        {`You Lose! ${computerSelection} beats ${playerSelection}`}

        else if ( (playerSelection == "Rock" && computerSelection =="Scissors") || (playerSelection == "Paper" && computerSelection =="Rock") || (playerSelection =="Scissors" && computerSelection =="Paper"))

        {`You Win! ${computerSelection} beats ${playerSelection}`}

        else {`It's a draw! ${computerSelection} and ${playerSelection} cancel eachother out`}  



The functions do not run automatically, you need to tell the function to run. For example, put playerSelection() at the end of your script and then that function should run.

1 Like

I changed up the code so the functions would run. Strange that the prompt in the if statement still gets triggered even if I enter ‘Paper’ as my choice

It was! I figgured that bit out. it was because i didnt put the playerChoice== in each of the ||(OR) parameters

Thank you. Saved me a further headache