#Looking for help

216 messages · Page 1 of 1 (latest)

narrow trellis
#

I am a beginner making a small project with rock paper scissors. I am trying to make an "endless" game where I have 3 types of scores: Player Win, Computer Win and Tied score. I can't seem to figure out where I am going wrong with score going up. Whenever I press a button score doesn't change.

#

let computerScoreDisplay = 0;
let userScoreDisplay = 0;
let tiedScoreDisplay = 0;

function addScore() {
if (userChoice === winner) {
userScoreDisplay ++
}
else if (computerChoice === winner) {
computerScoreDisplay++
}
else (tie === winner) {
tiedScoreDisplay++
}
}

This is my current attempt to get it work

half galleon
#

This is a tidy way to look at standard RPS logic:

if ( user == computer ) {
 // it's a tie
} else if ((user == 'paper' && computer == 'rock') || (user == 'rock' && computer == 'scissors') || (user == 'scissors' && computer == 'paper')) {
 // you won
} else {
 // you lose
}
```... but there's a million ways to approach it.
Over the holidays I had fun writing an RPS with auto. Over a lot of rounds the winner can be nicely random, I could see people betting on it. 😛
narrow trellis
#

this is what i currently have :

#

function determineWinner(userChoice,) {
const computerChoice = getComputerChoice();
let winner;
console.log('computerChoice : ', computerChoice);
console.log('user choice : ', userChoice)
if (userChoice === computerChoice) {
winner = "tie";
} else if ((userChoice === "rock" && computerChoice === "scissors") ||
(userChoice === "paper" && computerChoice === "rock") ||
(userChoice === "scissors" && computerChoice === "paper")) {
winner = "user";
} else { winner = "computer"; }
console.log(winner)
}

#

but I can't get into adding the scores to whoever wins

#

Besides, my computer prefer going 2 times into same thing 😛

half galleon
#

Discord supports markdown which is why your text looks quirky.
Try putting code inside of single `backticks` to avoid that or use three backticks followed by a code language ie ```js or ```javascript .. a new line, your code, and then three more backticks on a new line to end the code block.

keen egret
#

in the first message that you send you have if (userChoice === winner) { userScoreDisplay ++ } else if (computerChoice === winner) { computerScoreDisplay++ } else (tie === winner) {

#

did you want that to be winner === "user" or winner === "computer"?

half galleon
#

When I did it I had a statistics board tracking the number of times the player/computer picks each option.
It has to do something like:```js
if ( userChoice == computerChoice) {
// it's a tie
var elm = document.querySelector('td.computer.'+computerChoice);
elm.innerText = parseInt(elm.innerText) + 1;
var elm = document.querySelector('td.player.'+userChoice);
elm.innerText = parseInt(elm.innerText) + 1;
} else if ((userChoice== 'paper' && computerChoice== 'rock') || (userChoice== 'rock' && computerChoice == 'scissors') || (userChoice == 'scissors' && computerChoice == 'paper')) {
// you won
} else {
// you lose
}

narrow trellis
#

2nd one was supposed to assign winner to one of the 3 increment

keen egret
narrow trellis
keen egret
#

you can put them all in one if you really want

narrow trellis
#

For now its better to do both I'd say all in one sounds very complicated for my level currently

keen egret
#

but it looks like you are comparing the choices [rock/paper/scissor] with the winner [computer/user] and seeing if they are equal

narrow trellis
#

this is what I currently have

narrow trellis
keen egret
narrow trellis
#
function checkWinner() {
  let userWin = winner === userChoice;
  let computerWin = winner === computerChoice;
  let tieWin = winner === tie;
if (winner === userWin){
  incrementUserScore();
} else if(winner === computerWin){
  incrementComputerScore();
} else (winner === tieWin) {
  incrementTiedScore();}
}


this is a test to see If I posted code.```
keen egret
#

let userWin = winner === userChoice
means let userWin be either true or false based on if winner and userChoice is the same

#

so for example if (winner === userWin){ I think you want that to be if (userWin) or if (userWin===true)

narrow trellis
#
function checkWinner() {
  let userWin = winner === userChoice;
  let computerWin = winner === computerChoice;
  let tieWin = winner === tie;
if (userWin === true){
  incrementUserScore();
} else if(computerWin === true){
  incrementComputerScore();
} else (tieWin === true) {
  incrementTiedScore();}
}
#

like this ?

keen egret
#

yeah did that help?

narrow trellis
#

No the numbers stay the same after I play the g ame.

keen egret
#

can you show where you are calling checkWinner ?

narrow trellis
#

Nowhere besides that one line

#

also else statement comes back as an error

keen egret
#

supposed to be else if

narrow trellis
#

Yes that fixed it

#

as in the error message

keen egret
#

can you send the page?

#

like the code so I can try it out

narrow trellis
#
// Game variables //

const possibleChoices = ["rock", "paper", "scissors"];
const userDisplay = document.getElementById("userDisplay");
const computerDisplay = document.getElementById("computerDisplay");
const resultsDisplay = document.getElementById("resultsDisplay");
const userChoice = document.getElementById("userChoice");

// Event listeners //

const rockButton = document.getElementById("rock");
const paperButton = document.getElementById("paper");
const scissorsButton = document.getElementById("scissors");

rockButton.addEventListener("click", function () {
  determineWinner("rock");
});
paperButton.addEventListener("click", function () {
  determineWinner("paper");
});
scissorsButton.addEventListener("click", function () {
  determineWinner("scissors");
});

// Random number generation between 0 and 2 //

function getComputerChoice() {
  const computerChoice = possibleChoices[Math.floor(Math.random() * 3)];
  return computerChoice;
}

// Playing game using user's choice vs randomComputerChoice //
// @param {string} userChoice - The user's choice -- one of  rock, paper or scissors//

function determineWinner(userChoice,) {
  const computerChoice = getComputerChoice();
  let winner;
  console.log('computerChoice : ', computerChoice);
  console.log('user choice : ', userChoice)
  if (userChoice === computerChoice) { 
    winner = "tie";
  } else if ((userChoice === "rock" && computerChoice === "scissors") ||
    (userChoice === "paper" && computerChoice === "rock") ||
    (userChoice === "scissors" && computerChoice === "paper")) { 
      winner = "user"; 
  } else { winner = "computer"; }
  console.log(winner)
}

function checkWinner() {
  let userWin = winner === userChoice;
  let computerWin = winner === computerChoice;
  let tieWin = winner === tie;
if (userWin === true){
  incrementUserScore();
} else if(computerWin === true){
  incrementComputerScore();
} else if (tieWin === true) {
  incrementTiedScore();}
}

let userScoreResult = 0;
let computerScoreResult = 0;
let tiedScoreResult = 0;

//* Increment User score *//
function incrementUserScore() {
  let oldUserScore = parseInt(document.getElementById('userScoreDisplay').innerText);
  document.getElementById('userScoreDisplay').innerText = ++oldUserScore;
  console.log(incrementUserScore)
}

//* Increment Computer Score *//
function incrementComputerScore() {
  let oldComputerScore = parseInt(document.getElementById('computerScoreDisplay').innerText);
  document.getElementById('computerScoreDisplay').innerText = ++oldComputerScore;
}

//* Increment Tied Score *//
function incrementTiedScore() {
  let oldTiedScore = parseInt(document.getElementById('tiedScoreDisplay').innerText);
  document.getElementById('tiedScoreDisplay').innerText = oldTiedScore++;
}
keen egret
#

ok one sec

#

oh ok

#

you are not calling checkWinner anywhere

#

you just defined it

narrow trellis
#

ah that is the issue

keen egret
#

also I don't think winner can be accessed you will might have to add it like js function checkWinner(winner,userChoice,computerChoice,tie) {

#

and run js function checkWinner(winner,userChoice,computerChoice,tie) { at the end of determineWinner after the console.log(winner) line

#

and run checkWinner(winner) at the end of determineWinner after the console.log(winner)

#

and run checkWinner(winner) at the end of determineWinner after the console.log(winner)

narrow trellis
#

1 minute trying

keen egret
#

sorry I changed part of it because you have several variables I don't think you can access

narrow trellis
#

Do I add the whole function under determineWInner?

keen egret
#

you add js checkWinner(winner,userChoice,computerChoice,tie) under console.log(winner)

narrow trellis
#

okay

keen egret
#

cause you need to pass your checkWinner function those variables so that it can do the comparisons

#

the variables exist inside of the checkWinner function

narrow trellis
#
function determineWinner(userChoice,) {
  const computerChoice = getComputerChoice();
  let winner;
  console.log('computerChoice : ', computerChoice);
  console.log('user choice : ', userChoice)
  if (userChoice === computerChoice) { 
    winner = "tie"; 
  } else if ((userChoice === "rock" && computerChoice === "scissors") ||
    (userChoice === "paper" && computerChoice === "rock") ||
    (userChoice === "scissors" && computerChoice === "paper")) { 
      winner = "user"; checkWinner(); 
  } else { winner = "computer"; }
  console.log(winner)
  checkWinner(winner,userChoice,computerChoice,tie)
}

#

this is how I done it

#

I need to delete some parts

keen egret
#

"computer";checkWinner() } you should delete checkWinner from there

#

``` winner = "tie"; checkWinner();```` and here

narrow trellis
#

I done it

keen egret
#

winner = "user"; checkWinner(); and here

narrow trellis
#

I done all 3

keen egret
#

ok can you show me the line that says function checkWinner

narrow trellis
#
function determineWinner(userChoice,) {
  const computerChoice = getComputerChoice();
  let winner;
  console.log('computerChoice : ', computerChoice);
  console.log('user choice : ', userChoice)
  if (userChoice === computerChoice) { 
    winner = "tie";
  } else if ((userChoice === "rock" && computerChoice === "scissors") ||
    (userChoice === "paper" && computerChoice === "rock") ||
    (userChoice === "scissors" && computerChoice === "paper")) { 
      winner = "user";
  } else { winner = "computer"; }
  console.log(winner)
  checkWinner(winner,userChoice,computerChoice,tie)
}

function checkWinner(winner, userChoice,computerChoice,tie) {
  let userWin = winner === userChoice;
  let computerWin = winner === computerChoice;
  let tieWin = winner === tie;
if (userWin === true){
  incrementUserScore();
} else if(computerWin === true){
  incrementComputerScore();
} else if (tieWin === true) {
  incrementTiedScore();}
}

#

console.log(winner)
checkWinner(winner,userChoice,computerChoice,tie)
}

keen egret
#

ok nice

#

is it working now?

narrow trellis
#

No it doesn't

#

problem might be lying somewhere else then

#
<div id="scores">
<h3>Player:<span id="userScoreDisplay">0</span></h3>
<h3>Computer:<span id="computerScoreDisplay">0</span></h3>
<h3>Tied:<span id="tiedScoreDisplay">0</span></h3>
</div>

keen egret
#

is it console.logging(winner)?

narrow trellis
#

this is essentially what I am trying to increment

#

yes

#

wait

#

yes

#

It says who won

#

User / Computer / Tie

keen egret
#

ok in the incrementScore try adding a log

#

see if the functions are being called correctly

#

don't forget to put " " around the text though

narrow trellis
#
function incrementUserScore() {
  let oldUserScore = parseInt(document.getElementById(userScoreDisplay).innerText);
  document.getElementById(userScoreDisplay).innerText = ++oldUserScore;
  console.log(incrementUserScore)
}

#

You mean like this?

keen egret
#

console.log("incrementUserScore")

#

like that

#

or put "incremementing User score" or whatever is the most comfortable for you

narrow trellis
#

oh okay

#

1 sec

keen egret
#

but you need 1 for each of the increment functions cause it's random who wins

narrow trellis
#

DOesnt seem to work

#
function incrementUserScore() {
  let oldUserScore = parseInt(document.getElementById("userScoreDisplay").innerText);
  document.getElementById("userScoreDisplay").innerText = ++oldUserScore;
  console.log("incrementUserScore")
}
keen egret
#

it doesn't log anything?

narrow trellis
#

no

keen egret
#

did u put one one each?

narrow trellis
#

yes

#

on all 3

#
//* Increment User score *//
function incrementUserScore() {
  let oldUserScore = parseInt(document.getElementById("userScoreDisplay").innerText);
  document.getElementById("userScoreDisplay").innerText = ++oldUserScore;
  console.log("incrementUserScore")
}

//* Increment Computer Score *//
function incrementComputerScore() {
  let oldComputerScore = parseInt(document.getElementById("computerScoreDisplay").innerText);
  document.getElementById("computerScoreDisplay").innerText = ++oldComputerScore;
  console.log("incrementComputerScore")
}

//* Increment Tied Score *//
function incrementTiedScore() {
  let oldTiedScore = parseInt(document.getElementById("tiedScoreDisplay").innerText);
  document.getElementById("tiedScoreDisplay").innerText = oldTiedScore++;
  console.log("incrementTiedScore")
}

keen egret
#

oh

narrow trellis
keen egret
#

oh back in checkWinnerjs let userWin = winner === userChoice; let computerWin = winner === computerChoice; let tieWin = winner === tie;
should be ```js
let userWin = winner === "user";
let computerWin = winner === "computer;
let tieWin = winner === "tie";

narrow trellis
#

Yes, but it still the same the numbers dont go up

#

after changing it

keen egret
#

is the increment log going off now?

narrow trellis
#

No, could it be that Im using mixture of 'thing' and "thing"

keen egret
#

no that is ok

#

well not on the same string though

#

like "user' is not ok

narrow trellis
#

Then, there shouldn't be an issue in terms of that

keen egret
#

but "user" here and 'user' somewhere else should work but you should try and do one or the other when u get time

narrow trellis
#

I will keep it in mind "" is easier than ''

#

could:
let userScoreResult = 0;
let computerScoreResult = 0;
let tiedScoreResult = 0;

#

be the issue?

keen egret
#

I don't even see you using those

#

you can delete them since you never use them

narrow trellis
#

I put them there to increment them I guess thats the logic behind it

keen egret
#

the way that you have it looks like you are parsing whatever is on the page already and incrementing it

narrow trellis
#

They were inside my initial checkWInner

keen egret
#

btw you need to put the 0 in the html

narrow trellis
#
<div id="scores">
<h3>Player:<span id="userScoreDisplay">0</span></h3>
<h3>Computer:<span id="computerScoreDisplay">0</span></h3>
<h3>Tied:<span id="tiedScoreDisplay">0</span></h3>
</div>
#

the 0 is in span

keen egret
#

oh ok

#

can you send me the code again

#

you said the logging is not going off for increment right?

narrow trellis
#
// Game variables //

const possibleChoices = ["rock", "paper", "scissors"];
const userDisplay = document.getElementById("userDisplay");
const computerDisplay = document.getElementById("computerDisplay");
const resultsDisplay = document.getElementById("resultsDisplay");
const userChoice = document.getElementById("userChoice");

// Event listeners //

const rockButton = document.getElementById("rock");
const paperButton = document.getElementById("paper");
const scissorsButton = document.getElementById("scissors");

rockButton.addEventListener("click", function () {
  determineWinner("rock");
});
paperButton.addEventListener("click", function () {
  determineWinner("paper");
});
scissorsButton.addEventListener("click", function () {
  determineWinner("scissors");
});

// Random number generation between 0 and 2 //

function getComputerChoice() {
  const computerChoice = possibleChoices[Math.floor(Math.random() * 3)];
  return computerChoice;
}

// Playing game using user's choice vs randomComputerChoice //
// @param {string} userChoice - The user's choice -- one of  rock, paper or scissors//

function determineWinner(userChoice,) {
  const computerChoice = getComputerChoice();
  let winner;
  console.log('computerChoice : ', computerChoice);
  console.log('user choice : ', userChoice)
  if (userChoice === computerChoice) { 
    winner = "tie";
  } else if ((userChoice === "rock" && computerChoice === "scissors") ||
    (userChoice === "paper" && computerChoice === "rock") ||
    (userChoice === "scissors" && computerChoice === "paper")) { 
      winner = "user";
  } else { winner = "computer"; }
  console.log(winner)
  checkWinner(winner,userChoice,computerChoice,tie)
}

function checkWinner(winner, userChoice,computerChoice,tie) {
  let userWin = winner === "user";
  let computerWin = winner === "computer";
  let tieWin = winner === "tie";
if (userWin === true){
  incrementUserScore();
} else if(computerWin === true){
  incrementComputerScore();
} else if (tieWin === true) {
  incrementTiedScore();}
}

//* Increment User score *//
function incrementUserScore() {
  let oldUserScore = parseInt(document.getElementById("userScoreDisplay").innerText);
  document.getElementById("userScoreDisplay").innerText = ++oldUserScore;
  console.log("incrementUserScore")
}

//* Increment Computer Score *//
function incrementComputerScore() {
  let oldComputerScore = parseInt(document.getElementById("computerScoreDisplay").innerText);
  document.getElementById("computerScoreDisplay").innerText = ++oldComputerScore;
  console.log("incrementComputerScore")
}

//* Increment Tied Score *//
function incrementTiedScore() {
  let oldTiedScore = parseInt(document.getElementById("tiedScoreDisplay").innerText);
  document.getElementById("tiedScoreDisplay").innerText = ++oldTiedScore;
  console.log("incrementTiedScore")
}
#

yes

keen egret
#

oh tie is not defined

#

but you aren't using all those variables any more

#

change checkWinner lines to js checkWinner(winner)

#

for the function checkWinner and the line below console.log(winner)

#

and then try it

#

see if the log works

#

but it wasn't working before cause tie wasnt' defined

narrow trellis
#

on it

#

no it doesn't work still

keen egret
#

you changed both those lines and there is still no increment log?

narrow trellis
#

yes

keen egret
#

is it giving an error?

narrow trellis
#

There is an error but its more due to favicon

#

console.log() for increment doesn't say anything at all

#

maybe im missing () for increment inside console.log instead of ""

keen egret
#

give it a try or send what you have

narrow trellis
#
// Game variables //

const possibleChoices = ["rock", "paper", "scissors"];
const userDisplay = document.getElementById("userDisplay");
const computerDisplay = document.getElementById("computerDisplay");
const resultsDisplay = document.getElementById("resultsDisplay");
const userChoice = document.getElementById("userChoice");

// Event listeners //

const rockButton = document.getElementById("rock");
const paperButton = document.getElementById("paper");
const scissorsButton = document.getElementById("scissors");

rockButton.addEventListener("click", function () {
  determineWinner("rock");
});
paperButton.addEventListener("click", function () {
  determineWinner("paper");
});
scissorsButton.addEventListener("click", function () {
  determineWinner("scissors");
});

// Random number generation between 0 and 2 //

function getComputerChoice() {
  const computerChoice = possibleChoices[Math.floor(Math.random() * 3)];
  return computerChoice;
}

// Playing game using user's choice vs randomComputerChoice //
// @param {string} userChoice - The user's choice -- one of  rock, paper or scissors//

function determineWinner(userChoice,) {
  const computerChoice = getComputerChoice();
  let winner;
  console.log('computerChoice : ', computerChoice);
  console.log('user choice : ', userChoice)
  if (userChoice === computerChoice) { 
    winner = "tie";
  } else if ((userChoice === "rock" && computerChoice === "scissors") ||
    (userChoice === "paper" && computerChoice === "rock") ||
    (userChoice === "scissors" && computerChoice === "paper")) { 
      winner = "user";
  } else { winner = "computer"; }
  console.log(winner)
  checkWinner(winner)
}

function checkWinner(winner) {
  let userWin = winner === "user";
  let computerWin = winner === "computer";
  let tieWin = winner === "tie";
if (userWin === true){
  incrementUserScore();
} else if(computerWin === true){
  incrementComputerScore();
} else if (tieWin === true) {
  incrementTiedScore();}
}

//* Increment User score *//
function incrementUserScore() {
  let oldUserScore = parseInt(document.getElementById("userScoreDisplay").innerText);
  document.getElementById("userScoreDisplay").innerText = ++oldUserScore;
  console.log("incrementUserScore")
}

//* Increment Computer Score *//
function incrementComputerScore() {
  let oldComputerScore = parseInt(document.getElementById("computerScoreDisplay").innerText);
  document.getElementById("computerScoreDisplay").innerText = ++oldComputerScore;
  console.log("incrementComputerScore")
}

//* Increment Tied Score *//
function incrementTiedScore() {
  let oldTiedScore = parseInt(document.getElementById("tiedScoreDisplay").innerText);
  document.getElementById("tiedScoreDisplay").innerText = ++oldTiedScore;
  console.log("incrementTiedScore")
}

#

console.log("incrementTiedScore") tried as console.log(incrementTiedScore())

#

nothing changes

keen egret
#

oh you mean like that

#

no the " " version is what you want

#

if you put the function it will return undefined because those functions don't return anything

narrow trellis
#

yes

#
<section class="game-area">
<div id="possibleChoices">
    <button class="btn-rock"id="rock"> <i class="fa-solid fa-hand-back-fist"></i></button>
    <button class="btn-paper" id="paper"><i class="fa-solid fa-hand"></i></button>
    <button class="btn-scissors"id="scissors"><i class="fa-solid fa-hand-scissors"></i></button>
</div>
#

could this be cause of an issue? But I can select my options just fine

keen egret
#

that looks ok to me

narrow trellis
#

no

keen egret
#

but i'm not 100% sure on that

narrow trellis
#

it works

keen egret
#

it works now?

narrow trellis
#

Yes

keen egret
#

nice

narrow trellis
#

Apperantly it didnt save properly

#

log works

keen egret
#

lmao

narrow trellis
#

but it doesnt increment my scores regardless

#

it logs that its supposed to increment right areas though.

#

or is console.log causing the no score incrementation?

keen egret
#

oh

#

try putting the script in the html after the body

#

maybe it is not done with the dom by the time it loads the script

#

did that fix it?

narrow trellis
#

no it doesnt add up yet

keen egret
#

do you have the script tag like this

narrow trellis
#

</body>
<script src="././assets/js/script.js"></script>
</html

keen egret
#

is it giving an error now

#

also html is missing > although I don't think that has anything to do with the main problem

narrow trellis
#

thank you for pointing it out I would've missed it 😄

#

No errors though

keen egret
#

are you using chrome?

narrow trellis
#

Yes I am

keen egret
#

try going to sources

#

next to the console tab

#

and see if anything is highlighted

#

or has an x

#

the numbers are changing for me and I just changed the script location after what I had already mentioned

narrow trellis
#

Maybe I have incorrect number elswhere

#

I mean inside html

keen egret
#

can you send both files

narrow trellis
#
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="Description" content="Rock,Paper,Scissors">
    <link rel="stylesheet" href="assets/css/style.css">
    <script src="https://kit.fontawesome.com/a7d740db08.js" crossorigin="anonymous"></script>
    <title>Rock Paper Scissors </title>
</head>
<body>
<header>
    <h1> Rock, Paper, Scissors </h1>
</header>
<!-- Buttons-->
<section class="game-area">
<div id="possibleChoices">
    <button class="btn-rock"id="rock"> <i class="fa-solid fa-hand-back-fist"></i></button>
    <button class="btn-paper" id="paper"><i class="fa-solid fa-hand"></i></button>
    <button class="btn-scissors"id="scissors"><i class="fa-solid fa-hand-scissors"></i></button>
</div>


<!--Scores-->
<div id="scores">
<h3>Player:<span id="userScoreDisplay">0</span></h3>
<h3>Computer:<span id="computerScoreDisplay">0</span></h3>
<h3>Tied:<span id="tiedScoreDisplay">0</span></h3>
</div>


<button class="reset">Reset Game</button>

</section>
<footer>
    <h2>Rules:</h2>
    <p> Rock wins against Scissors | Scissors wins against Paper | Paper wins against Rock</p>
</footer>



</body>
<script src="././assets/js/script.js"></script>
</html>

#
// Game variables //

const possibleChoices = ["rock", "paper", "scissors"];
const userDisplay = document.getElementById("userDisplay");
const computerDisplay = document.getElementById("computerDisplay");
const resultsDisplay = document.getElementById("resultsDisplay");
const userChoice = document.getElementById("userChoice");

// Event listeners //

const rockButton = document.getElementById("rock");
const paperButton = document.getElementById("paper");
const scissorsButton = document.getElementById("scissors");

rockButton.addEventListener("click", function () {
  determineWinner("rock");
});
paperButton.addEventListener("click", function () {
  determineWinner("paper");
});
scissorsButton.addEventListener("click", function () {
  determineWinner("scissors");
});

// Random number generation between 0 and 2 //

function getComputerChoice() {
  const computerChoice = possibleChoices[Math.floor(Math.random() * 3)];
  return computerChoice;
}

// Playing game using user's choice vs randomComputerChoice //
// @param {string} userChoice - The user's choice -- one of  rock, paper or scissors//

function determineWinner(userChoice,) {
  const computerChoice = getComputerChoice();
  let winner;
  console.log('computerChoice : ', computerChoice);
  console.log('user choice : ', userChoice)
  if (userChoice === computerChoice) { 
    winner = "tie";
  } else if ((userChoice === "rock" && computerChoice === "scissors") ||
    (userChoice === "paper" && computerChoice === "rock") ||
    (userChoice === "scissors" && computerChoice === "paper")) { 
      winner = "user";
  } else { winner = "computer"; }
  console.log(winner)
  checkWinner(winner)
}

//* Check winner and increment the score *//

function checkWinner(winner) {
  let userWin = winner === "user";
  let computerWin = winner === "computer";
  let tieWin = winner === "tie";
if (userWin === true){
  incrementUserScore();
} else if(computerWin === true){
  incrementComputerScore();
} else if (tieWin === true) {
  incrementTiedScore();}
}

//* Increment User score *//
function incrementUserScore() {
  let oldUserScore = parseInt(document.getElementById("userScoreDisplay").innerText);
  document.getElementById("userScoreDisplay").innerText = oldUserScore++;
  console.log("incrementUserScore");
}

//* Increment Computer Score *//
function incrementComputerScore() {
  let oldComputerScore = parseInt(document.getElementById("computerScoreDisplay").innerText);
  document.getElementById("computerScoreDisplay").innerText = oldComputerScore++;
  console.log("incrementComputerScore");
}

//* Increment Tied Score *//
function incrementTiedScore() {
  let oldTiedScore = parseInt(document.getElementById("tiedScoreDisplay").innerText);
  document.getElementById("tiedScoreDisplay").innerText = oldTiedScore++;
  console.log("incrementTiedScore");
}

#

after I go through validator

#

it says im missing quite a few semicolons

keen egret
#

yeah

#

and your determine winner has a ,

narrow trellis
#

removed it

#

are you using mozilla or chrome?

keen egret
#

chrome

#

oh

#

you messed with the ++

narrow trellis
#

yes

keen egret
#

put it back to ++ in front

narrow trellis
#

oh my days

#

its working!!!

keen egret
#

let variable = ++a means increment a then assign it to variable a++ means let variable = a then a++ after

#

they do different things I actually saw you had them mixed before but thought u were testing something since it wasn't working

narrow trellis
#

I was

#

I had them mixed for up

#

then I decided to go in back ++

#

Didnt realise it would change it by that much

#

Woooo!

#

It only took me 2 days to get this working 😄

keen egret
#

yeah they are not interchangeable like the "" and '' thing

narrow trellis
#

Really appreciate the help

keen egret
#

np and grats on getting it working

narrow trellis
#

Thank you so much!!!

keen egret
#

np have fun

narrow trellis
#

You spent like 2 hours helping me out can't really express how much it means ;D

keen egret
#

it's alright maybe just help someone if you can one day

narrow trellis
#

I will!! once I know better what I am doing

half galleon