Need help with my code

I’m doing the rock paper scissors game but adding in buttons I’ve figured out how to get it to send back the players correct selection by button press with the event.target.id DOM method and my computerplay function is working as intended I’ve tested both out, but when I call my playround function both the player selection and computer selection are not comparing, nor giving me the results i’m looking for which is console logging if the user win, lose, tie or add points to the player’s or computer’s scores. chrome dev tools is not trowing back any errors, so I cant see what the problem is any help would be appreciated.

here is a link to my code
https://github.com/rsteward117/randy-s-rock-paper-scissors-game

Hi Randy,
First problem I see is that your computerplay() function is not returning anything so in playRound() you don’t have a value to compare the player choice with. So you can do it like that:

function computerplay(){
var cp = picks[(Math.random()*picks.length)|0];
return cp;
}

Or:

function computerplay(){
return picks[(Math.random()*picks.length)|0];
}

Second: in your playRound() function you declared:

const computerselection = computerplay();
const playerSelection = e.target.id;

Those are not constants, they will change in each round, better do it with let.
When you are comparing values better use === instead of ==.
Further down, in case of a computer win you’ve put **computerselection++*, I am sure you meant to put
computersScore++ as you want to increase that.

Third: your user score and computer score display will not update automatically, you have to do it inside the playRound() function. One way to do so is:

    console.log('you win!');
              usersScore++;
//updates the score display
              uscore.innerHTML = usersScore;

And:

console.log('you lose!');
          computersScore++;
 //updates the score display
          cscore.innerHTML = computersScore;

Keep up with the good work, I hope that helps :slight_smile: