Rock Paper Scissors not working


#1

Hello everyone! I’m stuck at RPS. As i open the console in my browser and try to console.log anything it keeps giving me this message “VM309:1 Uncaught ReferenceError: playerSelection is not defined
at :1:23” or Uncaught ReferenceError: computerPlay is not defined
my code:

<script>

function computerPlay(){
let choices = [‘rock’,‘paper’,‘scissors’]
return choice = choices[Math.floor(Math.random() * choices.length)];
}

function playRound(playerSelection, computerSelection){
if (playerSelection === ‘rock’ && computerSelection === ‘scissors’ || playerSelection === ‘paper’ && computerSelection === ‘rock’ || playerSelection === ‘scissors’ && computerSelection === ‘paper’) {
let win = 'You win! ’ + playerSelection + ’ beats ’ + computerSelection
}
else {
let lose = ‘You lose’
}
}

let playerSelection = ‘rock’
let computerSelection = computerPlay()


#2

I’m not 100% sure, but when I copied and pasted you code into VS Code, it did not like the kind of single quotes you were using… See how your single quotes have a slight curve, with a thicker part at the bottom or top. I switched them to the only kind of single quote that I have on my mac & it worked fine. I took 2 screen shots to show you:


#3

Thanks! this was the problem.