{"id":24633062,"url":"https://github.com/schoolofcode/bc16-w2-hackathon-rps-in-console-workshop-js-101-room20","last_synced_at":"2025-10-14T19:37:24.968Z","repository":{"id":238045726,"uuid":"757961757","full_name":"SchoolOfCode/bc16-w2-hackathon-rps-in-console-workshop-js-101-room20","owner":"SchoolOfCode","description":"bc16-w2-hackathon-rps-in-console-workshop-js-101-room20 created by GitHub Classroom","archived":false,"fork":false,"pushed_at":"2024-02-16T14:19:41.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-20T06:45:47.009Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SchoolOfCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-15T10:50:31.000Z","updated_at":"2024-05-04T00:15:06.000Z","dependencies_parsed_at":"2024-05-04T02:25:53.214Z","dependency_job_id":"b8136242-f883-462e-9be4-f515ae9c3a6d","html_url":"https://github.com/SchoolOfCode/bc16-w2-hackathon-rps-in-console-workshop-js-101-room20","commit_stats":null,"previous_names":["schoolofcode/bc16-w2-hackathon-rps-in-console-workshop-js-101-room20"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SchoolOfCode/bc16-w2-hackathon-rps-in-console-workshop-js-101-room20","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SchoolOfCode%2Fbc16-w2-hackathon-rps-in-console-workshop-js-101-room20","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SchoolOfCode%2Fbc16-w2-hackathon-rps-in-console-workshop-js-101-room20/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SchoolOfCode%2Fbc16-w2-hackathon-rps-in-console-workshop-js-101-room20/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SchoolOfCode%2Fbc16-w2-hackathon-rps-in-console-workshop-js-101-room20/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SchoolOfCode","download_url":"https://codeload.github.com/SchoolOfCode/bc16-w2-hackathon-rps-in-console-workshop-js-101-room20/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SchoolOfCode%2Fbc16-w2-hackathon-rps-in-console-workshop-js-101-room20/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020657,"owners_count":26086898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-25T08:13:42.907Z","updated_at":"2025-10-14T19:37:24.953Z","avatar_url":"https://github.com/SchoolOfCode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rock, Paper, Scissors!\n\nWork through the tasks below, which function as tickets, to build and refine your own rock, paper, scissors game where a player plays against the computer.\n\n## Task 0: Make a plan!\n\nAs always, before you jump into the code, the first step is to break down your logic and make a plan. This is especially useful when you're coding something more complex, like game logic!\n\nThe first step in breaking down the game of rock, paper, scissors might look something like this:\n\n- Run the game loop\n  - Store a move choice from a user (rock, paper, or scissors) in a variable\n  - Randomly generate the computer's move and store that in a variable\n  - Compare the two moves using the rock, paper, scissors rules to decide who won\n    - Rock beats scissors\n    - Scissors beats paper\n    - Paper beats rock\n- Alert the winner and update the scores accordingly (wins, losses, and draws)\n- Ask the player whether they want to play again\n\nThis is a start, but each of these steps can be broken down even further before you code. We've broken these down into the tasks below, but before you read and tackle them, we'd like you to try your hand at planning first.\n\nReminder of tools that you can use while planning:\n\n- A [flowchart](https://app.diagrams.net/) to visualise the game logic\n- Recording any assumptions you're making\n- What information you're storing in variables and when each should be updated\n- Pseudocode to plan out how you're going to translate your logic into actual code\n\n\u003cdetails\u003e\n\u003csummary\u003eMore about pseudocode\u003c/summary\u003e\n\nPseudocode is a way of writing out the logic of a program in a natural language that's easy to understand, without worrying about the specific syntax of any particular programming language. Developers use it to plan out their code.\n\nBy writing out the logic of a program in pseudocode, you can focus on the high-level concepts and flow of the program before worrying about the details of the syntax. This can make it easier to wrap your head around complex programming concepts and make sure you're approaching the problem in the right way.\n\nIt can help you communicate your ideas to others as well. Pseudocode is often used in technical documentation and specifications to describe the behavior of a program in a clear and concise way.\n\nHere's an example of how pseudocode might be used to plan out a simple JavaScript program that calculates the average of an array of numbers:\n\n```js\n\n// Define an array of numbers\n\n// Initialize a variable to hold the sum of the numbers, and start it at 0\n\n// Use a for loop to loop through the array and add each number to the sum\n\n// Calculate the average by dividing the sum by the number of numbers\n\n// Log the average to the console\n\n```\n\nThis pseudocode is written in a way that's easy to understand, even if you're not familiar with JavaScript syntax. Once you've worked out the logic of your program using pseudocode, you can then translate it into actual JavaScript code.\n\n\u003c/details\u003e\n\nWe'd recommend you take about 15 minutes to write out how you'd plan to code the game before diving into the tasks, and compare and contrast how you've planned with the tasks we've written out as you go.\n\n## Task 1: Logic\n\nTo complete this ticket you will need to write a set of if statements that will determine the winner of rock, paper, scissors.\n\nThe two moves should be stored in two variables like so:\n\n```js\nlet playerMove = \"rock\";\nlet computerMove = \"paper\";\n```\n\nYou'll want to hard-code each move in these variables (like the example above) to check each piece of logic at first.\n\nEach time you want to test a different combination of moves, change the hard-coded values for `playerMove` and `computerMove`, save the file, and then refresh the page. You'll be making these dynamic very soon!\n\n`console.log` the expected outcome (whether it's a win, loss, or draw) inside of each if block for now so you can see the outcome when you reload the page while testing each scenario.\n\nThis will be deemed as complete when all permutations of the three possible moves for each player have been handled correctly, e.g. rock vs rock is a draw, paper vs rock is a paper win, etc.\n\n## Task 2: Function\n\nTake the if statements that you've written and tested and put them into a function. The variables from before should now be taken in as parameters so that you can call the function with any two moves. Instead of printing the result to the console, the function should return:\n\n- `1` if player1 wins\n- `0` if it is a draw\n- `-1` if player1 loses (player2 wins)\n\nThe function should be able to be used like so:\n\n```js\nfunction getWinner(player1, player2) {\n  // code goes here...\n}\n\nlet result = getWinner(\"rock\", \"paper\");\n```\n\nThis will be deemed as complete when the function can be called with any combination of valid moves and returns the appropriate number.\n\n## Task 3: User Input\n\nUsing `prompt`, get a user-inputted value for the player move. Then call your function with that value as the player move and the hard-coded computer move. Display the result using `alert`.\n\nThis will be deemed as complete when you can input any move for the player move and hard-code any move for the computer move and see the correct result (1, 0, or -1) in the alert.\n\n## Task 4: Computer Player\n\nWrite a function that generates a random computer move. Use that function to make a dynamic game where the computer move is randomly chosen every time instead of being hard-coded.\n\n\u003cdetails\u003e\n\u003csummary\u003eHint\u003c/summary\u003e\n`Math.random()` might be useful!\n\u003c/details\u003e\n\nThis will be deemed as complete when the player can input any move in the prompt, the computer move is chosen by random, and the correct result shows in the alert.\n\n## Task 5: Game Loop\n\nNow that we have a fully functioning game, our next step is to have it run as many times as people would like to play without having to refresh the page.\n\nUse a `while loop` and `confirm`.\n\nThis will be deemed as complete when a player can keep playing indefinitely and has the option to stop playing after every round.\n\n## Task 6: Scores\n\nKeep track of how many games have been played, as well as the number of wins, losses, and draws.\n\nThis will be deemed as complete when this information is displayed after each round.\n\n## Task 7: Get the player's name using a prompt\n\nCreate a username `prompt` and use the username the player inputs in the game so that a player can see their name in the messages sent to them.\n\nTo make it more uniform, restrict the number of characters a username can be to 10 or fewer.\n\nThis will be deemed as complete when the users cannot enter a username longer than 10 characters.\n\n🌟 BONUS: Make it so that valid usernames should only start with letters, not numbers or symbols.  \n🌟 EXTRA BONUS: Make it so that the first letter of the username should be capitalised.\n\n## Bonus task extensions - pick whichever one(s) you fancy\n\n## Bonus A: Extend the logic\n\nRock, paper scissors is now boring. We need to jazz is up a bit.  \nAdd some more moves that a player can make.  \nCheck out this example:  \n![rock paper scissors lizard spock](./RPSLS.jpeg)\n\nModify your logic to represent your new version of this timeless children's game.\n\n## Bonus B: The Clairvoyant Computer\n\nHow would you go about making the computer win every time?\n\nHow would you go about making it so that the computer wins more often (1/2 the time, 1/4 of the time 90% of the time)?\n\nPlan how you'd go about implementing this (use pseudo-code).\n\nIf you have time, see if you can start writing this.\n\n## Bonus C: Better Presentation\n\nHow would you present the information in a better, more exciting way in the console? For example:\n\n- `console.table` lets you log information as a table\n- you can set the background colour and foreground colour of what you're logging to the console (search online for ways to do this)\n- `console.clear` lets you clear information\n- you can create ASCII art/images (or get them online) and log them to the console\n\nGet creative. Plan how you'd go about implementing this (use pseudo-code).\n\nIf you have time, see if you can build this functionality.\n\n## Bonus D:\n\nKeep going! Improve, refactor, look for ways to do things differently, look for new things in JavaScript you haven't used yet that you could integrate! The world is your oyster.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschoolofcode%2Fbc16-w2-hackathon-rps-in-console-workshop-js-101-room20","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschoolofcode%2Fbc16-w2-hackathon-rps-in-console-workshop-js-101-room20","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschoolofcode%2Fbc16-w2-hackathon-rps-in-console-workshop-js-101-room20/lists"}