Although I have completed this task I can’t figure how why
“else if (hasPlayerWonTheRound === computerResult)” makes sense. We are comparing a boolean value (true or false) with a string (Rock, Paper or Scissor) how can this be part of the solution?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function getRoundResults(userOption) {
const computerResult = getRandomComputerResult();
if (hasPlayerWonTheRound) {
playerScore +
return `Player wins! ${userOption} beats ${computerResult}`;
}
else if (hasPlayerWonTheRound === computerResult) {
return `It's a tie! Both chose ${userOption}`;
}
else {
computerScore ++;
return `Computer wins! ${computerResult} beats ${userOption}`;
}
}
console.log(getRoundResults("Rock"));
console.log("Player Score: ", playerScore, "Computer Score: ", computerScore);
// 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/122.0.0.0 Safari/537.36
Challenge Information:
Review DOM Manipulation by Building a Rock, Paper, Scissors Game - Step 3
First there’s a syntax error and then your tie condition doesn’t seem to work?
// running tests
2. Your getRoundResults function should return the correct message based on who wins the round. If no one wins, the message should say it's a tie.
// tests completed
As well, hasPlayerWonTheRound is the name of the function, but it’s not actually calling the function, so it doesn’t return a boolean
When I fix up the syntax errors, the code does pass.
It looks like the tests don’t actually test if a tie outputs the correct message, the else if condition is never satisfied.
When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
// running tests
2. Your getRoundResults function should return the correct message based on who wins the round. If no one wins, the message should say it's a tie.
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.