Rock Paper Scissors Project

I feel like a fool, but i can’t figure out why the function to get a random variable stops working when calling into the play round function. Any tips or hints would be appreciated, i’ve been look at it for hours.

function computerPlay(options)
{

         return options[Math.floor(Math.random()*options.length)];
}
         var options = ['rock', 'paper', 'scissors'];

function playRound(){

if (playerSelection === 'rock' && computerSelection === 'paper') {
  return 'Player Wins ' + playerSelection + ' ' + computerSelection
}
if (playerSelection === 'paper' && computerSelection === 'rock') {
    return 'Player Wins ' + playerSelection + ' ' + computerSelection
}
if (playerSelection === 'scissors' && computerSelection === 'paper'){
    return 'Player Wins ' + playerSelection + ' ' + computerSelection
}
if (playerSelection === 'paper' && computerSelection === 'scissors') {
    return 'Computer Wins ' + playerSelection + ' ' + computerSelection
  }
  if (playerSelection === 'scissors' && computerSelection === 'rock') {
      return 'Computer Wins ' + playerSelection + ' ' + computerSelection
  }
  if (playerSelection === 'paper' && computerSelection === 'scissors'){
      return 'Player Wins ' + playerSelection + ' ' + computerSelection
  }
  else if (playerSelection === computerSelection){
  return 'draw' + playerSelection + ' ' + computerSelection
}

}

const playerSelection = ‘scissors’;
let computerSelection = computerPlay(options);
console.log(computerSelection)

Do you have this live somewhere on a WYSIWYG editor others could fork / play with? (Codepen, fiddle, PlayCode …)

IDK if it’s just bad copypasta, but I got an error for

const playerSelection = 'scissors';

And had to redo the quotes.

Also, as it is, each function runs once because nothing is calling either of them more than once. If you add:

console.log(playRound(playerSelection))

You’ll see an outcome, which to me so far looks correct. If you want to play multiple games you’ll need a function to handle that.

The code says function computerPlay(options), but nowhere in your code do you pass the options parameter to the function, and in reality you don’t need to pass this function anything.

This code is just generating a random move and outputting the appropriate value, instead of taking in a value, then using it to do work.

Change computerPlay(options) to just computerPlay() and it should work fine from there.