Skip to content

Chandrakala - my first webdev fellowship assignment #207

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions assignment1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
let rock = 'rock';
let scissors = 'scissors';
let paper = 'paper';

// these two variables will be changed to test the conditional
let firstPlayerChoice;
let secondPlayerChoice;

let firstPossibility;
let secondPossibility;
let thirdPossibility;

let fourthPossibility;
let fifthPossibility;
let sixthPossibility;

let seventhPossibility;

// 3. store the first scenario in the firstPossibility variable
firstPossibility = firstPlayerChoice === rock && secondPlayerChoice === scissors;

// 4. do the same for the other five possibilities with a winner
secondPossibility = firstPlayerChoice === scissors && secondPlayerChoice === paper;
thirdPossibility = firstPlayerChoice === paper && secondPlayerChoice === rock;
fourthPossibility = secondPlayerChoice === rock && firstPlayerChoice === scissors;
fifthPossibility = secondPlayerChoice === scissors && firstPlayerChoice === paper;
sixthPossibility = secondPlayerChoice === paper && firstPlayerChoice === rock;

// 5 store the value of a player tie, meaning the choices are the same
seventhPossibility = firstPlayerChoice === secondPlayerChoice;

// 6, 7, 8. The conditional with the four possible outcomes!
if (firstPossibility || secondPossibility || thirdPossibility) {
console.log(`first player won!`);
} else if (fourthPossibility || fifthPossibility || sixthPossibility) {
console.log(`second player won!`);
} else if (seventhPossibility) {
console.log('there is a tie! pick again');
} else {
console.log('something went wrong!');
}