-
-
Notifications
You must be signed in to change notification settings - Fork 40.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rock Paper Scissor #7734
Comments
Suggested roadmapYou will build a Rock-Paper-Scissors game where the computer randomly selects a move, and the player’s move is compared against it to determine a winner. This project will focus on using JavaScript, Node.js, and backend fundamentals. Project Objectives
Suggested Steps
Sample Code Outlinefunction getRandomMove() {
const moves = ["rock", "paper", "scissors"];
return moves[Math.floor(Math.random() * moves.length)];
}
function determineWinner(playerMove, computerMove) {
if (playerMove === computerMove) return "Draw";
if (
(playerMove === "rock" && computerMove === "scissors") ||
(playerMove === "scissors" && computerMove === "paper") ||
(playerMove === "paper" && computerMove === "rock")
) {
return "Player wins!";
} else {
return "Computer wins!";
}
}
const playerMove = "rock"; // This could come from user input
const computerMove = getRandomMove();
console.log(`Player: ${playerMove}, Computer: ${computerMove}`);
console.log(determineWinner(playerMove, computerMove)); |
this would have be great for someone just starting their journey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What Roadmap is this project for?
Backend
Project Difficulty
Beginner
Add Project Details
Build a rock paper scissor game using random function
The text was updated successfully, but these errors were encountered: