Tell us what’s happening:
I don’t know what to do next. How do I have access to each choice made by the player. I cannot use an event listener. I need guidance
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
if(hasPlayerWonTheRound(playerChoice, computerResult) === true){
playerScore ++;
return `Player wins! ${userOption} beats ${computerResult}`
}
else if(userOption === computerResult){
`It's a tie! Both chose ${userOption}`
}
else{
computerScore ++;
return `Computer wins! ${computerResult} beats ${userOption}`
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36
Challenge Information:
Build a Rock, Paper, Scissors Game - Step 6
GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-rps-game/66cf33305293e1b35c1aef7f.md at main · freeCodeCamp/freeCodeCamp · GitHub
ILM
August 27, 2026, 12:01pm
2
you are writing inside this function, right?
function getRoundResults(userOption) {
const computerResult = getRandomComputerResult();
}
that means you have userOption and computerResult available, playerChoice does not exist here
userOption has no value yet, it’s a parameter.
const options = ["Rock", "Paper", "Scissors"];
function getRandomComputerResult() {
const randomIndex = Math.floor(Math.random() * options.length);
return options[randomIndex];
}
function hasPlayerWonTheRound(playerChoice, computerChoice) {
return (
(playerChoice === "Rock" && computerChoice === "Scissors") ||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
(playerChoice === "Paper" && computerChoice === "Rock")
);
}
let playerScore = 0;
let computerScore = 0;
function getRoundResults(userOption) {
const computerResult = getRandomComputerResult();
if(hasPlayerWonTheRound(userOption, computerResult) === true){
playerScore ++;
return `Player wins! ${userOption} beats ${computerResult}`
}
else if(!hasPlayerWonTheRound(userOption, computerResult)){
computerScore ++;
return `Computer wins! ${computerResult} beats ${userOption}`
}
else{
`It's a tie! Both chose ${userOption}`
}
}
ILM
August 27, 2026, 12:22pm
4
it will have a value when the function is called, yes
What should I do? I am clueless.
ILM
August 27, 2026, 12:30pm
6
If the computer and player choose the same option, return the message "It's a tie! Both chose [player's choice]".
did you implement this correctly?
remember hasPlayerWonTheRound can only return true or false so there is no else situation
“Your resetGame function should set the playerScore to 0.”
This is what I see anytime I tried to check my code and I can’t seem to find the issue in my code.
const options = ["Rock", "Paper", "Scissors"];
function getRandomComputerResult() {
const randomIndex = Math.floor(Math.random() * options.length);
return options[randomIndex];
}
function hasPlayerWonTheRound(playerChoice, computerChoice) {
return (
(playerChoice === "Rock" && computerChoice === "Scissors") ||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
(playerChoice === "Paper" && computerChoice === "Rock")
);
}
let playerScore = 0;
let computerScore = 0;
function getRoundResults(userOption) {
const computerResult = getRandomComputerResult();
if (hasPlayerWonTheRound(userOption, computerResult)) {
playerScore++;
return `Player wins! ${userOption} beats ${computerResult}`;
} else if (computerResult === userOption) {
return `It's a tie! Both chose ${userOption}`;
} else {
computerScore++;
return `Computer wins! ${computerResult} beats ${userOption}`;
}
}
const playerScoreSpanElement = document.getElementById("player-score");
const computerScoreSpanElement = document.getElementById("computer-score");
const roundResultsMsg = document.getElementById("results-msg");
const winnerMsgElement = document.getElementById("winner-msg");
const optionsContainer = document.querySelector(".options-container");
const resetGameBtn = document.getElementById("reset-game-btn");
function showResults(userOption) {
roundResultsMsg.innerText = getRoundResults(userOption);
computerScoreSpanElement.innerText = computerScore;
playerScoreSpanElement.innerText = playerScore;
if (playerScore === 3 || computerScore === 3) {
winnerMsgElement.innerText = `${
playerScore === 3 ? "Player" : "Computer"
} has won the game!`;
resetGameBtn.style.display = "block";
optionsContainer.style.display = "none";
}
};
function resetGame(){
playerScore = 0;
computerScore = 0;
computerScoreSpanElement.innerText = computerScore;
playerScoreSpanElement.innerText = playerScore;
resetGameBtn.style.display = "none";
optionsContainer.style.display = "block";
roundResultsMsg.innerText = "";
winnerMsg.innerText = "";
}
resetGameBtn.addEventListener("click", resetGame);
const rockBtn = document.getElementById("rock-btn");
const paperBtn = document.getElementById("paper-btn");
const scissorsBtn = document.getElementById("scissors-btn");
rockBtn.addEventListener("click", function () {
showResults("Rock");
});
paperBtn.addEventListener("click", function () {
showResults("Paper");
});
scissorsBtn.addEventListener("click", function () {
showResults("Scissors");
});
Teller
August 28, 2026, 5:18am
8
Hi @Emmysifire
Your solution works from my end. Please try one of the following steps to move forward.
Click on the “Restart Step” button and force a refresh of your page with CTRL + F5 then try to paste the code in again.
or - Try the step in incognito or private mode.
or - Disable any/all extensions that interface with the freeCodeCamp website (such as Dark Mode, Ad Blockers, or Spellcheckers), and set your browser zoom level to 100%. Both of these factors can cause tests to fail erroneously.
or - Ensure your browser is up-to-date or try a different browser.
I hope one of these will work for you.
Happy coding