- Fork and Clone Rock, Paper, Scissors Repo
- Ensure you have installed all dependencies/packages:
npm i
- Practice running the unit tests for the program:
npm test main.js
- Use a whiteboard to find a solution to the Rock, Paper, Scissors program
- Translate the broad ideas to psuedo code
- Convert the psuedo code to real JavaScript Code
- Type into your text editor the JavaScript code you've come up with one step at a time
- Work through your bugs.
- Play the game with the command:
node main.js
- Achieve green checks for each of your unit tests.
Build a function,that will take in an input from a user then another input from another user and compare them against one another to determine the winner of the game!
- Build a rock, paper, scissors game.
- Use the code plan below to get started.
- Start out by white boarding which means writing in English (no code) each step of that needs to be coded.
- User1 input of rock, paper, or scissors.
- User2 input of rock, paper, or scissors.
- Compare User1 input to User2 input.
- If User1 input is 'rock' and User2 input is 'scissor', User1 wins.
- If User1 input is 'rock' and User2 input is 'paper', User2 wins.
- If User1 input is 'rock' and User2 input is 'rock', it's a tie.
- If User1 input is 'paper' and User2 input is 'rock', User1 wins.
- If User1 input is 'paper' and User2 input is 'scissors', User2 wins.
- If User1 input is 'paper' and User2 input is 'paper', it's a tie.
- If User1 input is 'scissors' and User2 input is 'paper', User1 wins.
- If User1 input is 'scissors' and User2 input is 'rock', User2 wins.
- If User1 input is 'scissors' and User2 input is 'scissors', it's a tie.
Can you think of a simpler way?
<iframe src="https://player.vimeo.com/video/377156267" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>- What should the program return if the user inputs something that isn't "rock", "paper", or "scissors"?
- Can you use
.trim()
to solve the problem if a user types in a space with their input? - Minimize redundancy: D.R.Y. up your code. Are their ways to not type as much as you've typed? Can you make the code smaller?
- Compartmentalize your code into individual functions. This game doesn't have to run just one function, can you pull code blocks out and put them into other functions that can be called from
rockPaperScissors
?
- Read ALL of the comments in
main.js
- Read the Objective and Code Planning section above.
- Use the JS Docs at MDN to convert long if/else statements to switch case statements.
- Push yourself further
- Clone, setup, testing, and running instructions for all projects is below
-
Click the 'Fork' button (choose your account if prompted).
-
Copy HTTPS URL from your forked repository
-
In your terminal/gitBash/CommandPrompt navigate (using
cd
) into a directory where you want to start keeping your repositories. (/jsDevFolder
) -
Clone your new repository by typing
git clone <forked clone URL>
(the HTTPS URL you copied above) -
Now go into the new directory by using
cd project-repo
-
Add the base repository as an upstream
git remote add upstream https://github.com/AustinCodingAcademy/<PROJECT-REPO>.git
-
Check the configuration of your remotes with
git remote -v
, it should look very similar to this (except it'll be YOUR username)
$ git remote -v
origin git@github.com:username/javascript-workbook.git (fetch)
origin git@github.com:username/javascript-workbook.git (push)
upstream git@github.com:AustinCodingAcademy/javascript-workbook.git (fetch)
upstream git@github.com:AustinCodingAcademy/javascript-workbook.git (push)
-
From your project directory, run
npm i
to tell NPM to install all the node modules we use in this class (seepackage.json
) -
Use your textEditor (VS Code) to change your files.
-
When you're finished
git status
, stage your filegit add .
, commit your changesgit commit -m "functions working"
, and push to GitHubgit push
git status git add . git commit -m "Initial Commit" git push origin gh-pages
-
Now go to your forked repository on GitHub (at https://github.com/your-username/javascript-workbook). A little yellow box should have popped up asking you to make a Pull Request. Click to review.
-
Click "Create Pull Request"
-
Every time you make a change and push to GitHub, this PR will automatically update. No need to do it more than once.
Simply run node path/to/file.js
example node 01week/rockPaperScissors.js
Tests are a great way to make sure you code works the way you planned it would, and to make sure you don't break something in the future. We will be using them to test our understanding of the lesson. It's also our main way to assign grades for an assignment.
To run a the tests on a file run npm test path/to/file.js
, etc.
Simply run npm run lint
- Run
npm start
- To break out of the server, press
ctrl
+c
-
To get the latest code/homework/test updates, be sure to have a "clean working directory" by committing or removing all of your changes. You check for a "clean working environment" by running
git status
and making sure no files show up. -
Run
git pull upstream gh-pages