mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-07 15:03:20 -04:00
chore(curriculum): update rps-game instructions and hasPlayerWonTheRound parameter (#62310)
This commit is contained in:
@@ -9,7 +9,7 @@ dashedName: step-4
|
||||
|
||||
In this step, you will focus on determining if the player has won the round.
|
||||
|
||||
Create a `hasPlayerWonTheRound` function with two parameters called `player` and `computer`.
|
||||
Create a `hasPlayerWonTheRound` function with two parameters called `playerChoice` and `computerChoice`. These parameters will take string values of either `"Rock"`, `"Paper"`, or `"Scissors"`, representing the selections made by the player and the computer.
|
||||
|
||||
The function should return `true` if the player has won the round, and `false` if the player has lost or tied the round.
|
||||
|
||||
@@ -27,10 +27,10 @@ You should have a function called `hasPlayerWonTheRound`.
|
||||
assert.isFunction(hasPlayerWonTheRound);
|
||||
```
|
||||
|
||||
Your function should have two parameters called `player` and `computer`.
|
||||
Your function should have two parameters called `playerChoice` and `computerChoice`.
|
||||
|
||||
```js
|
||||
assert.match(code, /hasPlayerWonTheRound\s*(?:=\s*)?\(\s*player\s*,\s*computer\s*\)\s*/);
|
||||
assert.match(code, /hasPlayerWonTheRound\s*(?:=\s*)?\(\s*playerChoice\s*,\s*computerChoice\s*\)\s*/);
|
||||
```
|
||||
|
||||
Your `hasPlayerWonTheRound` function should return a boolean.
|
||||
|
||||
@@ -205,11 +205,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -240,11 +240,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,11 +214,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -259,11 +259,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -491,11 +491,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -218,11 +218,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -218,11 +218,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -218,11 +218,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -231,11 +231,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -218,11 +218,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,11 +195,11 @@ function getRandomComputerResult() {
|
||||
return options[randomIndex];
|
||||
}
|
||||
|
||||
function hasPlayerWonTheRound(player, computer) {
|
||||
function hasPlayerWonTheRound(playerChoice, computerChoice) {
|
||||
return (
|
||||
(player === "Rock" && computer === "Scissors") ||
|
||||
(player === "Scissors" && computer === "Paper") ||
|
||||
(player === "Paper" && computer === "Rock")
|
||||
(playerChoice === "Rock" && computerChoice === "Scissors") ||
|
||||
(playerChoice === "Scissors" && computerChoice === "Paper") ||
|
||||
(playerChoice === "Paper" && computerChoice === "Rock")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user