Review DOM Manipulation by Building a Rock, Paper, Scissors Game - Step 2

Tell us what’s happening:

I am struggling to get a “false” output from the code.
The hint “Your hasPlayerWonTheRound function should return false if the player and computer chose the same option.” does not help. I tried to include every constellation e.g. player === “Rock”, computer === “Rock” as else if statement.

What is wrong here?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

function hasPlayerWonTheRound(player, computer) {
  if (player === "Rock", computer === "Scissors") {
    return true;
  } else if (player === "Scissors", computer === "Paper") {
    return true;
  } else if (player === "Paper", computer === "Rock") {
    return true;
  } else if (player === "Rock", computer === "Rock") { 
    return false;
  } else if (player === computer) {
    return false;
  } else {
    return false;
  }
}

console.log(hasPlayerWonTheRound("Rock", "Scissors")); 
console.log(hasPlayerWonTheRound("Scissors", "Rock")); 

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0

Challenge Information:

Review DOM Manipulation by Building a Rock, Paper, Scissors Game - Step 2

Hey, a comma in a condition isnt the call here, normally for things like params and arrays. Replace this with one of the other operands. Good luck

1 Like