{"id":10718,"date":"2023-02-19T18:00:08","date_gmt":"2023-02-19T12:30:08","guid":{"rendered":"http:\/\/myprojectideas.com\/?p=10718"},"modified":"2025-10-13T06:00:44","modified_gmt":"2025-10-13T06:00:44","slug":"rock-paper-scissors-game-in-javascript","status":"publish","type":"post","link":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/","title":{"rendered":"Rock-Paper Scissors Game In JavaScript"},"content":{"rendered":"<h2><strong>Introduction of the Project<\/strong><\/h2>\n<p>Welcome to the world of game development using JavaScript! In this tutorial, we will be walking you through the steps of building a Rock-Paper-Scissors game in JavaScript. Rock-Paper-Scissors is a classic game that is easy to learn and fun to play. The rules are simple &#8211; each player chooses either rock, paper, or scissors, and the winner is determined by a simple set of rules. Rock beats scissors, paper beats rock, and scissors beat paper.<\/p>\n<p>By the end of this tutorial, you will have built a fully functional Rock-Paper-Scissors game that you can share with your friends or even integrate into your website. We will cover the basics of HTML, CSS, and JavaScript to help you get started, and we will walk you through each step of the development process.<\/p>\n<p>We will develop a method that enables a user to choose between rock, paper &amp; scissors, and based upon the computer\u2019s choice, it updates the scoreboard. So let&#8217;s get started!<\/p>\n<h2><strong>Objectives<\/strong><\/h2>\n<p>We have listed down the objectives for building a Rock-Paper-Scissors game in JavaScript:<\/p>\n<p>1. To practice and improve your skills in JavaScript programming, including variables, functions, and conditional statements.<\/p>\n<p>2. To learn how to manipulate the <a href=\"https:\/\/www.w3schools.com\/js\/js_htmldom.asp\">DOM (Document Object Model)<\/a> using JavaScript to update the user interface of a webpage dynamically.<\/p>\n<p>3. To create a fun and engaging game that can be played and enjoyed by yourself and others. We will make the pictures of rock, paper &amp; scissors clickable so that user can choose their option &amp; then compare it with computer\u2019s choice to make changes in the scoreboard.<\/p>\n<p>4. To enhance your understanding of user input and event handling, as well as error handling.<\/p>\n<p>5. To gain experience working with HTML and CSS in conjunction with JavaScript to build an interactive web application.<\/p>\n<p>6. To explore the different possibilities of implementing game logic and how it can be structured.<\/p>\n<p>7. To gain experience in refactoring code to improve efficiency and readability.<\/p>\n<p>8. To learn how to use external libraries or frameworks to help with the development process.<\/p>\n<p>9. To practice debugging and testing skills to ensure the game functions correctly.<\/p>\n<p>10. To gain a better understanding of game design principles and mechanics, including the concept of strategy and probability in the Rock-Paper-Scissors game.<\/p>\n<h2><strong>Requirements<\/strong><\/h2>\n<p>1. <a href=\"https:\/\/code.visualstudio.com\/\">Visual Studio Code<\/a> or any other IDE<\/p>\n<p>2. <strong>HTML:<\/strong> You should be familiar with the structure of an HTML document, as you will need to create an HTML page to display the game and accept user input.<\/p>\n<p>3.<strong> CSS:<\/strong> You should have a basic understanding of CSS to style your HTML page and make it visually appealing.<\/p>\n<p>4. <strong>JavaScript:<\/strong> You should have a solid understanding of JavaScript programming, including variables, data types, functions, and conditional statements.<\/p>\n<p>5. <strong>DOM manipulation:<\/strong> You should understand how to manipulate the <em>Document Object Model (DOM)<\/em> using JavaScript to update the content of your HTML page dynamically.<\/p>\n<p>6. <strong>Event handling:<\/strong> You should understand how to handle user input events, such as clicking a button or pressing a key, to trigger actions within your JavaScript code.<\/p>\n<p>7. <strong>Basic game logic:<\/strong> You should understand the basic game logic of Rock-Paper-Scissors, including the rules for winning and losing, as well as the concept of ties.<\/p>\n<p>8. <strong>Testing and debugging:<\/strong> You should know how to test and debug your code to ensure that it is functioning correctly.<\/p>\n<h2><strong>Source Code<\/strong><\/h2>\n<h3><strong>HTML Code<\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&lt;!DOCTYPE html&gt;\r\n\r\n&lt;head&gt;\r\n\r\n&lt;title&gt;\r\n\r\nRock Paper Scissors Game\r\n\r\n&lt;\/title&gt;\r\n\r\n&lt;link rel=\"stylesheet\" href=\"rock_paper_scissors.css\"&gt;\r\n\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;header&gt;\r\n\r\n&lt;h1&gt;Rock Paper Scissors&lt;\/h1&gt;\r\n\r\n&lt;\/header&gt;\r\n\r\n&lt;div class=\"score_board\"&gt;\r\n\r\n&lt;div id=\"user_level\" class=\"badge\"&gt;user&lt;\/div&gt;\r\n\r\n&lt;div id=\"computer_level\" class=\"badge\"&gt;computer&lt;\/div&gt;\r\n\r\n&lt;spam id=\"user_score\"&gt;0&lt;\/spam&gt; : &lt;spam id=\"computer_score\"&gt;0&lt;\/spam&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;div class=\"result\"&gt;\r\n\r\n&lt;h3&gt;\r\n\r\nPaper covers Rock. You win.\r\n\r\n&lt;h3&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;div class=\"choices\"&gt;\r\n\r\n&lt;div class=\"choice\" id=\"r\"&gt;\r\n\r\n&lt;img src=\"rock.png\" alt=\"\"&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;div class=\"choice\" id=\"p\"&gt;\r\n\r\n&lt;img src=\"paper.png\" alt=\"\"&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;div class=\"choice\" id=\"s\"&gt;\r\n\r\n&lt;img src=\"scissors.png\" alt=\"\"&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;\/div&gt;\r\n\r\n&lt;p id=\"actionmsg\"&gt;\r\n\r\nMake your move\r\n\r\n&lt;\/p&gt;\r\n\r\n&lt;script src=\"rps.js\"&gt;&lt;\/script&gt;\r\n\r\n&lt;\/body&gt;<\/pre>\n<h3><strong>CSS Code<\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">*{\r\n\r\nmargin: 0;\r\n\r\npadding: 0;\r\n\r\nbox-sizing: border-box;\r\n\r\n}\r\n\r\nheader{\r\n\r\npadding: 20px;\r\n\r\nbackground-color: white;\r\n\r\n}\r\n\r\nheader &gt; h1{\r\n\r\ncolor: #0d0d1c;\r\n\r\nfont-family: sans-serif;\r\n\r\ntext-align: center;\r\n\r\n}\r\n\r\nbody{\r\n\r\nbackground: #0d0d1c;\r\n\r\n}\r\n\r\n.score_board{\r\n\r\nborder-style: solid ;\r\n\r\nborder-color: whitesmoke;\r\n\r\nmargin: 20px auto;\r\n\r\nwidth: 200px;\r\n\r\ncolor: white;\r\n\r\nfont-family: sans-serif;\r\n\r\ntext-align: center;\r\n\r\npadding: 15 px 20 px;\r\n\r\nfont-size: 46px;\r\n\r\nposition: relative;\r\n\r\nborder-radius:4px;\r\n\r\n}\r\n\r\n.badge\r\n\r\n{\r\n\r\nbackground-color: red;\r\n\r\ncolor:white;\r\n\r\nfont-size: 14px;\r\n\r\npadding: 2px 10px;\r\n\r\nfont-family: sans-serif;\r\n\r\n}\r\n\r\n#user_level\r\n\r\n{\r\n\r\nposition: absolute;\r\n\r\ntop: 20px;\r\n\r\nleft: -25px;\r\n\r\nfont-size: 14px;\r\n\r\n}\r\n\r\n#computer_level\r\n\r\n{\r\n\r\nposition: absolute;\r\n\r\ntop: 20px;\r\n\r\nleft: 150px;\r\n\r\nfont-size: 14px;\r\n\r\n}\r\n\r\n.result{\r\n\r\ncolor: white;\r\n\r\ntext-align: center;\r\n\r\nfont-family: sans-serif;\r\n\r\n}\r\n\r\n#actionmsg{\r\n\r\ncolor: white;\r\n\r\ntext-align: center;\r\n\r\n}\r\n\r\n.choices{\r\n\r\nmargin: 50px;\r\n\r\ntext-align: center;\r\n\r\n}\r\n\r\n.choice{\r\n\r\ndisplay: inline-block;\r\n\r\nborder-style: solid ;\r\n\r\nborder-color: whitesmoke;\r\n\r\nborder-radius: 50%;\r\n\r\npadding: 10px;\r\n\r\nmargin: 0 20px;\r\n\r\ntransition: all 0.4s ease;\r\n\r\n}\r\n\r\n.choice:hover{\r\n\r\ncursor: pointer;\r\n\r\nbackground-color: #000012;\r\n\r\n}<\/pre>\n<h3><strong>JAVASCRIPT Code<\/strong><\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\">var user_score=0;\r\n\r\nvar computer_score=0;\r\n\r\nconst userscore_span= document.getElementById(\"user_score\");\r\n\r\nconst computerscore_span= document.getElementById(\"computer_score\");\r\n\r\nconst scoreboard_div=document.querySelector(\".score_board\");\r\n\r\nconst result_h3=document.querySelector(\".result &gt; h3\");\r\n\r\nconst rock_div= document.getElementById(\"r\");\r\n\r\nconst paper_div= document.getElementById(\"p\");\r\n\r\nconst scissors_div= document.getElementById(\"s\");\r\n\r\nfunction word(letter)\r\n\r\n{\r\n\r\nif(letter === 'r')\r\n\r\nreturn \"Rock\";\r\n\r\nif(letter === 's')\r\n\r\nreturn \"Scissors\";\r\n\r\nreturn \"Paper\";\r\n\r\n}\r\n\r\nfunction win(userChoice , computerChoice)\r\n\r\n{\r\n\r\nuser_score++;\r\n\r\nuserscore_span.innerHTML= user_score;\r\n\r\ncomputerscore_span.innerHTML= computer_score;\r\n\r\nresult_h3.innerHTML= word(userChoice)+\"(U)\"+ \" beats \" +word(computerChoice)+\"(C)\" + \".YOU WIN \";\r\n\r\n}\r\n\r\nfunction lose(userChoice , computerChoice)\r\n\r\n{\r\n\r\ncomputer_score++;\r\n\r\nuserscore_span.innerHTML= user_score;\r\n\r\ncomputerscore_span.innerHTML= computer_score;\r\n\r\nresult_h3.innerHTML= word(computerChoice)+\"(C)\"+ \" beats \" +word(userChoice)+\"(U)\" + \".YOU LOSE \";\r\n\r\n}\r\n\r\nfunction draw(userChoice , computerChoice)\r\n\r\n{\r\n\r\nuserscore_span.innerHTML= user_score;\r\n\r\ncomputerscore_span.innerHTML= computer_score;\r\n\r\nresult_h3.innerHTML= \"DRAW\";\r\n\r\n}\r\n\r\nfunction getComputerChoice()\r\n\r\n{\r\n\r\nconst choices= ['r','p','s'];\r\n\r\nconst randomNumber=Math.floor(Math.random()*3);\r\n\r\nreturn choices[randomNumber];\r\n\r\n}\r\n\r\nfunction game(userChoice)\r\n\r\n{\r\n\r\nconst computerChoice=getComputerChoice();\r\n\r\nconsole.log(\"user choice \" +userChoice);\r\n\r\nconsole.log(\"computer choice \" +computerChoice);\r\n\r\nswitch(userChoice + computerChoice)\r\n\r\n{\r\n\r\ncase \"rs\":\r\n\r\ncase \"pr\":\r\n\r\ncase \"sp\":\r\n\r\nwin(userChoice,computerChoice);\r\n\r\nbreak;\r\n\r\ncase \"sr\":\r\n\r\ncase \"rp\":\r\n\r\ncase \"ps\":\r\n\r\nlose(userChoice,computerChoice);\r\n\r\nbreak;\r\n\r\ncase \"ss\":\r\n\r\ncase \"rr\":\r\n\r\ncase \"pp\":\r\n\r\ndraw(userChoice,computerChoice);\r\n\r\nbreak;\r\n\r\n}\r\n\r\n}\r\n\r\nfunction main()\r\n\r\n{\r\n\r\nrock_div.addEventListener('click', function()\r\n\r\n{\r\n\r\ngame('r');\r\n\r\n});\r\n\r\npaper_div.addEventListener('click', function()\r\n\r\n{\r\n\r\ngame('p');\r\n\r\n});\r\n\r\nscissors_div.addEventListener('click', function()\r\n\r\n{\r\n\r\ngame('s');\r\n\r\n});\r\n\r\ngetComputerChoice();\r\n\r\n}\r\n\r\nmain();<\/pre>\n<h2><strong>Explanation of the Code<\/strong><\/h2>\n<p>We have divided the source code into 3 different sections. <em>The first two are HTML &amp; CSS, which involve creating the GUI and styling it.\u00a0<\/em><\/p>\n<p>1. Our code contains multiple <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/div\">&lt;div&gt;<\/a> tags to denote scoreboard.<\/p>\n<p>2. The user interface consists of 3 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/img\">&lt;img&gt;<\/a> tags to denote rock, paper &amp; scissors, respectively.<\/p>\n<p>3. We have also provided a button, <em><strong>\u201cRESET\u201d<\/strong><\/em> to refresh the screen.<\/p>\n<p>4. The CSS file is meant for styling the html where the container is provided with appropriate margin, padding, and font colour and font size.<\/p>\n<p><em>The JavaScript code is for setting up the logic for the game:<\/em><\/p>\n<p>1. We have used the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Math\/random\">random() method<\/a> of Math class to choose among rock, paper &amp; scissors as a computer\u2019s choice.<\/p>\n<p>2. We take the user\u2019s input by applying click listeners to images.<\/p>\n<p>3. Finally, we make the possibilities of user winning, losing or drawing the match, then update the scoreboard accordingly.<\/p>\n<h2><strong>Output<\/strong><\/h2>\n<p><strong>Main Interface<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-17762 size-full\" src=\"https:\/\/rudelabs.ai\/blogs\/wp-content\/uploads\/2023\/02\/word-image-10718-1.webp\" alt=\"Rock-Paper Scissors Game In JavaScript\" width=\"1920\" height=\"1080\" \/><\/p>\n<h2><strong>Points To Remember<\/strong><\/h2>\n<p>We have successfully developed a rock-paper-scissors game in JavaScript. The game is being played against the computer with a nice scoreboard. It is a very fun &amp; famous game which can be easily played from this simple website. Here is a sum up of key points you sh<\/p>\n<ul>\n<li><strong>Set up your HTML page:<\/strong> Create an HTML page with the necessary elements, such as buttons for the player to select rock, paper, or scissors and a display area to show the game results.<\/li>\n<li><strong>Style your HTML page:<\/strong> Use CSS to style your HTML page and make it visually appealing.<\/li>\n<li><strong>Write the game logic:<\/strong> Write the JavaScript code that implements the game logic, including the rules for winning and losing and the handling of ties.<\/li>\n<li><strong>Handle user input:<\/strong> Use event listeners to handle user input and trigger the appropriate actions within your JavaScript code.<\/li>\n<li><strong>Update the game display:<\/strong> Use DOM manipulation to update the game display with the results of each round, including the choices made by the player and the computer and the outcome of the round.<\/li>\n<li><strong>Implement error handling:<\/strong> Implement error handling to ensure that the game works correctly even if unexpected input is entered.<\/li>\n<li><strong>Refactor your code:<\/strong> Refactor your code to improve its efficiency and readability and to make it easier to maintain and update.<\/li>\n<li><strong>Test and debug your code:<\/strong> Test your game thoroughly to ensure that it works correctly in a variety of scenarios, and debug any errors that arise.<\/li>\n<li><strong>Consider additional features:<\/strong> Consider adding additional features, such as a score tracker or a sound effect when a round is won.<\/li>\n<li><strong>Publish and share:<\/strong> Publish your game online, either on your own website or on a platform such as CodePen, and share it with others to play and enjoy.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/rudelabs.ai\/blogs\/category\/java\/\"><em><strong>More JavaScript Projects&gt;&gt;&gt;<\/strong><\/em><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rock-Paper-Scissors is a classic game &#8211; each player chooses either rock, paper, or scissors, and the winner is determined by a simple set of rules.<\/p>\n","protected":false},"author":1,"featured_media":10719,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-10718","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding-projects"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Rock-Paper Scissors Game In JavaScript - RUDE LABS<\/title>\n<meta name=\"description\" content=\"Welcome to the world of game development using JavaScript! In this tutorial, we will be walking you through the steps of building a Rock-Paper-Scissors game in JavaScript.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Rock-Paper Scissors Game In JavaScript - RUDE LABS\" \/>\n<meta property=\"og:description\" content=\"Welcome to the world of game development using JavaScript! In this tutorial, we will be walking you through the steps of building a Rock-Paper-Scissors game in JavaScript.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"RUDE LABS\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-19T12:30:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-13T06:00:44+00:00\" \/>\n<meta name=\"author\" content=\"rudelabs.ai\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rudelabs_in\" \/>\n<meta name=\"twitter:site\" content=\"@rudelabs_in\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rudelabs.ai\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/\"},\"author\":{\"name\":\"rudelabs.ai\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/560bad88bae03cae99a326a46af0c894\"},\"headline\":\"Rock-Paper Scissors Game In JavaScript\",\"datePublished\":\"2023-02-19T12:30:08+00:00\",\"dateModified\":\"2025-10-13T06:00:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/\"},\"wordCount\":1014,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#organization\"},\"image\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#primaryimage\"},\"thumbnailUrl\":\"\",\"articleSection\":[\"Coding Projects\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/\",\"url\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/\",\"name\":\"Rock-Paper Scissors Game In JavaScript - RUDE LABS\",\"isPartOf\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#primaryimage\"},\"thumbnailUrl\":\"\",\"datePublished\":\"2023-02-19T12:30:08+00:00\",\"dateModified\":\"2025-10-13T06:00:44+00:00\",\"description\":\"Welcome to the world of game development using JavaScript! In this tutorial, we will be walking you through the steps of building a Rock-Paper-Scissors game in JavaScript.\",\"breadcrumb\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#primaryimage\",\"url\":\"\",\"contentUrl\":\"\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/rudelabs.ai\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Rock-Paper Scissors Game In JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#website\",\"url\":\"https:\/\/rudelabs.ai\/blogs\/\",\"name\":\"RUDE LABS\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/rudelabs.ai\/blogs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#organization\",\"name\":\"RUDE LABS\",\"url\":\"https:\/\/rudelabs.ai\/blogs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/rudelabs.ai\/blogs\/wp-content\/uploads\/2025\/09\/RUDE-LABS.webp\",\"contentUrl\":\"https:\/\/rudelabs.ai\/blogs\/wp-content\/uploads\/2025\/09\/RUDE-LABS.webp\",\"width\":2459,\"height\":414,\"caption\":\"RUDE LABS\"},\"image\":{\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/rudelabs_in\",\"https:\/\/www.linkedin.com\/company\/ru-delabs\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/560bad88bae03cae99a326a46af0c894\",\"name\":\"rudelabs.ai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4d9f672e72f97294dfb6fac3d78e9f0bb5421a701cd2141cf2a2e540b4d67191?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4d9f672e72f97294dfb6fac3d78e9f0bb5421a701cd2141cf2a2e540b4d67191?s=96&d=mm&r=g\",\"caption\":\"rudelabs.ai\"},\"sameAs\":[\"https:\/\/rudelabs.ai\/blogs\"],\"url\":\"https:\/\/rudelabs.ai\/blogs\/author\/rudelabs-ai\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Rock-Paper Scissors Game In JavaScript - RUDE LABS","description":"Welcome to the world of game development using JavaScript! In this tutorial, we will be walking you through the steps of building a Rock-Paper-Scissors game in JavaScript.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Rock-Paper Scissors Game In JavaScript - RUDE LABS","og_description":"Welcome to the world of game development using JavaScript! In this tutorial, we will be walking you through the steps of building a Rock-Paper-Scissors game in JavaScript.","og_url":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/","og_site_name":"RUDE LABS","article_published_time":"2023-02-19T12:30:08+00:00","article_modified_time":"2025-10-13T06:00:44+00:00","author":"rudelabs.ai","twitter_card":"summary_large_image","twitter_creator":"@rudelabs_in","twitter_site":"@rudelabs_in","twitter_misc":{"Written by":"rudelabs.ai","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#article","isPartOf":{"@id":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/"},"author":{"name":"rudelabs.ai","@id":"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/560bad88bae03cae99a326a46af0c894"},"headline":"Rock-Paper Scissors Game In JavaScript","datePublished":"2023-02-19T12:30:08+00:00","dateModified":"2025-10-13T06:00:44+00:00","mainEntityOfPage":{"@id":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/"},"wordCount":1014,"commentCount":0,"publisher":{"@id":"https:\/\/rudelabs.ai\/blogs\/#organization"},"image":{"@id":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#primaryimage"},"thumbnailUrl":"","articleSection":["Coding Projects"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/","url":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/","name":"Rock-Paper Scissors Game In JavaScript - RUDE LABS","isPartOf":{"@id":"https:\/\/rudelabs.ai\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#primaryimage"},"image":{"@id":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#primaryimage"},"thumbnailUrl":"","datePublished":"2023-02-19T12:30:08+00:00","dateModified":"2025-10-13T06:00:44+00:00","description":"Welcome to the world of game development using JavaScript! In this tutorial, we will be walking you through the steps of building a Rock-Paper-Scissors game in JavaScript.","breadcrumb":{"@id":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/rudelabs.ai\/blogs\/rock-paper-scissors-game-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rudelabs.ai\/blogs\/"},{"@type":"ListItem","position":2,"name":"Rock-Paper Scissors Game In JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/rudelabs.ai\/blogs\/#website","url":"https:\/\/rudelabs.ai\/blogs\/","name":"RUDE LABS","description":"","publisher":{"@id":"https:\/\/rudelabs.ai\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rudelabs.ai\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/rudelabs.ai\/blogs\/#organization","name":"RUDE LABS","url":"https:\/\/rudelabs.ai\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rudelabs.ai\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/rudelabs.ai\/blogs\/wp-content\/uploads\/2025\/09\/RUDE-LABS.webp","contentUrl":"https:\/\/rudelabs.ai\/blogs\/wp-content\/uploads\/2025\/09\/RUDE-LABS.webp","width":2459,"height":414,"caption":"RUDE LABS"},"image":{"@id":"https:\/\/rudelabs.ai\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/rudelabs_in","https:\/\/www.linkedin.com\/company\/ru-delabs\/"]},{"@type":"Person","@id":"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/560bad88bae03cae99a326a46af0c894","name":"rudelabs.ai","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rudelabs.ai\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4d9f672e72f97294dfb6fac3d78e9f0bb5421a701cd2141cf2a2e540b4d67191?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d9f672e72f97294dfb6fac3d78e9f0bb5421a701cd2141cf2a2e540b4d67191?s=96&d=mm&r=g","caption":"rudelabs.ai"},"sameAs":["https:\/\/rudelabs.ai\/blogs"],"url":"https:\/\/rudelabs.ai\/blogs\/author\/rudelabs-ai\/"}]}},"_links":{"self":[{"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/posts\/10718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/comments?post=10718"}],"version-history":[{"count":1,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/posts\/10718\/revisions"}],"predecessor-version":[{"id":17763,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/posts\/10718\/revisions\/17763"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/media?parent=10718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/categories?post=10718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rudelabs.ai\/blogs\/wp-json\/wp\/v2\/tags?post=10718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}