{"id":53373,"date":"2022-11-11T01:11:01","date_gmt":"2022-11-11T07:11:01","guid":{"rendered":"https:\/\/www.codewizardshq.com\/?p=53373"},"modified":"2025-08-26T05:34:19","modified_gmt":"2025-08-26T11:34:19","slug":"javascript-tutorial-for-kids-rock-paper-scissors","status":"publish","type":"post","link":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/","title":{"rendered":"JavaScript Tutorial for Kids: Rock, Paper, Scissors"},"content":{"rendered":"\n<p>Is rock, paper, scissors more about skill or luck? Everyone has their own theory, but it&#8217;s one of those games that we all love to play when we\u2019re bored.<\/p>\n\n\n\n<p><strong>The logic is relatively simple, so it&#8217;s an easy game for beginners to turn into code too. <\/strong>You can replicate this game in any coding language, but JavaScript is a great way to play.<\/p>\n\n\n<p style=\"background: none repeat scroll 0 0 #ecf3f6; clear: both; margin-bottom: 18px; overflow: hidden; border: 1px solid #011e41; padding: 16px;\"><span>\ud83d\udccc<\/span><small><strong> [Download] JavaScript Projects Source Code<\/strong> Get the full source code for seven JavaScript project examples. <a href=\"#download\">Download Now<\/a><\/small><\/p>\n\n\n\n<p>In this tutorial, we\u2019ll automate a game of Rock, Paper, Scissors versus the computer. Use computational thinking to setup the game and handle the possible game outcomes. Follow this tutorial to build your own rock, paper, scissors game and try out your luck (or skills!).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-complete-this-javascript-tutorial-to-make-your-own-rock-paper-scissors-game\"><strong>Complete this JavaScript tutorial to make your own Rock, Paper, Scissors game.<\/strong><\/h3>\n\n\n\n<p>Play the completed <a href=\"https:\/\/projects.codewizardshq.com\/x_hour_of_code_2022\/javascript-projects\/rock-paper-scissors\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">Rock, Paper, Scissors<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/6Yvbo3GliY-iWjU6oR6aaY7STs384v1K76-2njJCaEWfaZvov87Jf5ssRj8Z0hxlIN5wuB1frf3J_L-fa7RFgV7oNpgkCRWpENoi1UzXKV2v-8Ud7H2pxB5uzBhY84mq3zVZemIEcPXcSSO-DnFdW1ioTwMXqAMr1t_zICEkzNjF8eH0HQ98piBRVl0_5A\" alt=\"Rock paper scissors javascript game\"\/><\/figure>\n\n\n\n<p><em>Recommended: <a href=\"https:\/\/www.codewizardshq.com\/javascript-for-kids\/\"><strong>JavaScript for Kids<\/strong><\/a><\/em><\/p>\n\n\n<div class=\"lazyblock-cw1-wide-post-container-NN5o3 wp-block-lazyblock-cw1-wide-post-container\"><div class=\"wide \"><div class=\"lazyblock-inner-blocks\">\n\n<div class=\"wp-block-atomic-blocks-ab-container table-of-contents ab-block-container\"><div class=\"ab-container-inside\"><div class=\"ab-container-content\">\n<p class=\"has-text-align-left title\"><strong>Tutorial Steps<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#step1\">Step 1: Add some setup code to handle the player&#8217;s choice<\/a><\/li>\n\n\n\n<li><a href=\"#step2\">Step 2: Add logic to handle the player\u2019s choice<\/a><\/li>\n\n\n\n<li><a href=\"#step3\">Step 3: Show an emoji on the page for the computer&#8217;s choice<\/a><\/li>\n\n\n\n<li><a href=\"#step4\">Step 4: Shuffle the computer&#8217;s emoji choices<\/a><\/li>\n\n\n\n<li><a href=\"#step5\">Step 5: Pick a random emoji for the computer<\/a><\/li>\n\n\n\n<li><a href=\"#step6\">Step 6: Decide who won the game<\/a><\/li>\n\n\n\n<li><a href=\"#complete\">Finished project!<\/a><\/li>\n<\/ul>\n<\/div><\/div><\/div>\n\n<\/div><\/div><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-you-need\">What you need:<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-text-editor\">1. Text editor<\/h3>\n\n\n\n<p><strong>We\u2019ll be using the CodeWizardsHQ editor to write and run our JavaScript code.<\/strong><\/p>\n\n\n\n<p>You can also use an online text editor like <a href=\"https:\/\/replit.com\/\">replit<\/a> that allows you to author and run JavaScript programs in a web browser. Make sure you have all of the project base files in order for your program to work correctly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-base-files\">2. Base Files<\/h3>\n\n\n\n<p><a href=\"https:\/\/drive.google.com\/drive\/folders\/1Z1IwoHNq2WYvKMETUdx4Ffb4hL0pQK3_?usp=share_link\">Download the base files<\/a> and open the app.js file. This folder contains all the images and files you will need to complete your game.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The HTML file holds the page title, emojis, and Player\/Computer choice text.&nbsp;<\/li>\n\n\n\n<li>The CSS file adds some styling to our page and helps lay out the HTML elements.&nbsp;<\/li>\n\n\n\n<li>The <code>error-handler.js<\/code> file will display a big red error box on the page if you make an error while typing out your JavaScript code.&nbsp;<\/li>\n\n\n\n<li>The <code>app.js<\/code> file is where we&#8217;ll write our application code.<\/li>\n<\/ul>\n\n\n\n<p>If you\u2019re a CodeWizardsHQ student, download the <code>x_hour_of_code_2022<\/code> project for the completed code. The starter files are in the <code>javascript-projects\/rock-paper-scissors\/starter-files<\/code> directory.&nbsp;<\/p>\n\n\n\n<p><strong>Note:<\/strong> The <code>index.html<\/code> file (which executes the JavaScript) expects the filename <code>app.js<\/code> so you must use the same file name if you&#8217;re using your own text editor! You&#8217;ll edit the <code>app.js<\/code> file but you&#8217;ll always run the <code>index.html<\/code> file.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-this-tutorial-is-for-beginner-javascript-programmers-ages-8-it-assumes-you-understand-basic-html-css-and-javascript-let-s-get-started\"><strong>This tutorial is for beginner JavaScript programmers ages 8+. It assumes you understand basic HTML\/CSS and JavaScript. Let&#8217;s get started!<\/strong><\/h3>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step1\">Step 1: Add some setup code to handle the player&#8217;s choice.<\/h2>\n\n\n\n<p>We&#8217;ll begin by adding code to set up when the player clicks the emoji to make their choice.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Open the <code>app.js<\/code> file,<\/strong> all of the code in this tutorial will go into this file.<\/li>\n\n\n\n<li><strong>Create a <code>playerChoice <\/code>variable representing the player&#8217;s choice and set it to an empty string (the <code>\"\"<\/code> characters denote a string).<\/strong> We&#8217;ll declare this variable at the top of our file because we want to use it in a few places\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Note: <\/strong>We&#8217;ll define all of our functions at the bottom of the file, and leave the variable declarations, event listener registration, and function calls at the top of our file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark>var playerChoice = \"\";<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Use <code>document.querySelector() <\/code>to select the <code>#player-choice-container<\/code> HTML element (the <code>#<\/code> means this is the ID of the element) and store it in a variable called <code>playerChoiceContainer<\/code>.<\/strong> This is the section that holds the player\u2019s emojis.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var playerChoice = \"\";\n\n<mark>var playerChoiceContainer = document.querySelector(\"#player-choice-container\");<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Attach an event listener to the<code> playerChoiceContainer<\/code> that will run the <code>handlePlayerChoice()<\/code> function (which we&#8217;ll create next) whenever this container with the player\u2019s emojis is clicked.&nbsp;<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var playerChoiceContainer = document.querySelector(\"#player-choice-container\");\n\n<mark>playerChoiceContainer.addEventListener(\"click\", handlePlayerChoice);<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Create a function called <code>handlePlayerChoice()<\/code> that records the players emoji selection. <\/strong>Since this is an event-handler function attached to a click event, use an <code>event <\/code>parameter representing the click event in the parenthesis. Note that there is no change in the output for this step!<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>playerChoiceContainer.addEventListener(\"click\", handlePlayerChoice);\n<mark>\nfunction handlePlayerChoice(event) {\n\n}<\/mark><\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/rock-paper-scissors-html-css.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"587\" src=\"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/rock-paper-scissors-html-css-1024x587.jpg\" alt=\"rock paper scissors step 1\" class=\"wp-image-53860\" srcset=\"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/rock-paper-scissors-html-css-1024x587.jpg 1024w, https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/rock-paper-scissors-html-css-300x172.jpg 300w, https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/rock-paper-scissors-html-css-768x440.jpg 768w, https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/rock-paper-scissors-html-css-1536x880.jpg 1536w, https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/rock-paper-scissors-html-css.jpg 1935w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"step2\">Step 2: Add logic to handle the player\u2019s choice<\/h2>\n\n\n\n<p>Once the player clicks on their emoji choice, we need to add logic that will save their choice and display it on the screen.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In the <code>handlePlayerChoice()<\/code> function, add an if statement.<\/strong> If the element that was clicked (the <code>event.target<\/code>) does not (<code>!<\/code>) contain the class emoji, we will exit the function. This means that if a player clicks next to an emoji, none of the other function code runs. If they click on an emoji, it will run. The <code>return <\/code>statement exits a function immediately and can optionally return a value to the function caller.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function handlePlayerChoice(event) {\n    <mark>if (!event.target.classList.contains(\"emoji\")) return;<\/mark>\n\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Get the text content of the clicked element (the emoji) and save it in the <code>playerChoice <\/code>variable. <\/strong>We\u2019ll then change the <code>innerHTML<\/code> of the <code>playerChoiceContainer <\/code>to only display the emoji that was clicked.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function handlePlayerChoice(event) {\n    if (!event.target.classList.contains(\"emoji\")) return;\n<mark>\n    playerChoice = event.target.textContent;\n    playerChoiceContainer.innerHTML = `&lt;p class=\"emoji\"&gt;${playerChoice}&lt;\/p&gt;`;\n<\/mark>\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2 Output<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/OlhLiJMsBQ3Wc9z4Lbaydl3gX_zY-dLZHjHz1t2-zicMDTjkpzkwxcY-mQUAjeB-Ik8p6xkNqzFdyk36sVL3QjLz7mguQF2KgWcZcHrwlAh80rb3Osx7UwMzAIO03_65dqNrnkJ5hvx1Q9zzaX8BwUfBuczmWgz2qVJU-cQ0WDPahnQ6wAGB8aKAwnH5Lw\" alt=\"rock paper scissors step 2\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step3\">Step 3: Show an emoji on the page for the computer&#8217;s choice<\/h2>\n\n\n\n<p>We&#8217;ll create a function that will eventually shuffle the emojis on the page and display the computer&#8217;s choice. In this step, we&#8217;ll create the function and display a single emoji choice on the page.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Create a variable called <code>computerChoice <\/code>that will hold the computer&#8217;s choice.<\/strong> We want to be able to access the variable in a few places so we&#8217;ll create it at the top of our file to ensure that it is global.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var playerChoice = \"\";\n<mark>var computerChoice = \"\";<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Create an array, a type of data that holds several items in a single variable, called <code>emojis <\/code>that holds the Rock, Paper, and Scissors emoji characters. <\/strong>Note that the scissors emoji needs to have an additional space after the emoji, as the quote characters overlap the emoji if you don&#8217;t add a space on the right-hand side in most text editors.&nbsp;<\/li>\n<\/ul>\n\n\n\n<p><br>You can find each emoji here:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>https:\/\/emojipedia.org\/rock\/\n<ul class=\"wp-block-list\">\n<li>\ud83e\udea8<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>https:\/\/emojipedia.org\/page-facing-up\/\n<ul class=\"wp-block-list\">\n<li>\ud83d\udcc4<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>https:\/\/emojipedia.org\/scissors\/\n<ul class=\"wp-block-list\">\n<li>\u2702\ufe0f<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var playerChoice = \"\";\nvar computerChoice = \"\";\n\/*\n * Note that the scissors emoji has to have an extra space!\n *\/\n<mark>var emojis = &#091;\"\u2702\ufe0f \", \"\ud83d\udcc4\", \"\ud83e\udea8\"];<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In a variable called <code>emojiShuffleElement<\/code>, use <code>document.querySelector(<\/code>) to get a reference to the <code>#emoji-shuffle<\/code> element.<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var emojis = &#091;\"\u2702\ufe0f \", \"\ud83d\udcc4\", \"\ud83e\udea8\"];\n\nvar playerChoiceContainer = document.querySelector(\"#player-choice-container\");\n<mark>var emojiShuffleElement = document.querySelector(\"#emoji-shuffle\");<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Next, create a function called <code>shuffleEmojis()<\/code>. <\/strong>This will eventually shuffle through the computer\u2019s three emojis on a timer, but right now, it&#8217;ll simply pick whatever emoji we ask for from the <code>emojis<\/code> array and display it on the page. (Don&#8217;t type the <code>...<\/code> characters. Those are an indicator that we&#8217;re leaving out code you don&#8217;t need to worry about right now.)<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function handlePlayerChoice(event) {\n    ...\n}\n<mark>\nfunction shuffleEmojis() {\n\n}<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Get an item from the<code> emojis<\/code> array and store it in the <code>computerChoice<\/code> variable. <\/strong>We use the <code>[]<\/code> brackets to access array items at an index number. Array indices start at 0, so the first element is at index 0, the second at index 1, etc. Here, we select the second item, the Paper emoji.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function shuffleEmojis() {\n    <mark>computerChoice = emojis&#091;1];<\/mark>\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Get the text inside of your <code>emojiShuffleElement <\/code>variable<\/strong> by setting the <code>textContent <\/code>of the <code>emojiShuffleElement <\/code>to the <code>computerChoice <\/code>(which represents the emoji text). If you don&#8217;t need to change the HTML of an element, the <code>textContent <\/code>property is an easy way to display text on the screen.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function shuffleEmojis() {\n    computerChoice = emojis&#091;1];\n    <mark>emojiShuffleElement.textContent = computerChoice;<\/mark>\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Next, call the <code>shuffleEmojis()<\/code> function<\/strong>. You should now see your chosen emoji appear under the &#8220;Computer&#8217;s Choice&#8221; text. Try changing the index number to a different emoji&#8217;s index in&nbsp;<code>shuffleEmojis()<\/code> to see if the emoji on the page changes! Note that you&#8217;ll need to refresh the page after each change in order to see the changes take effect.&nbsp;&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>playerChoiceContainer.addEventListener(\"click\", handlePlayerChoice);\n\n<mark>shuffleEmojis();<\/mark>\n\nfunction handlePlayerChoice(event) {\n  ...\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3 Output<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/g3FQmd04PJ1v1AGezS_h2wf2_EMRh2EgL4upLbkNz5a51CHABC8RmvM3KzGRXvkumBtOhYU3vg-ggab4IvoV2J3YnF5UnPi9tg3oeW1hCHicZkVypLQtEXSnHEfcZ8VTeNMmJiFQH06NnQLR7hTS3P6EIUfRphOfpt1aVHBzZdMHP1xeUJX_Q9HcRPzD0A\" alt=\"rock paper scissors step 3\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step4\">Step 4: Shuffle the computer&#8217;s emoji choices<\/h2>\n\n\n\n<p>We&#8217;ll create a shuffle animation that shuffles through the Rock, Paper, and Scissors emojis quickly. This makes it seem like the computer is thinking about what choice it will randomly select.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Create a variable called <code>currentEmojiNumber<\/code><\/strong> that will hold the index number of the emoji we&#8217;re currently displaying on the page during the shuffling process. We&#8217;ll start with the first index in the <code>emojis<\/code> array, index 0.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var emojis = &#091;\"\u2702\ufe0f \", \"\ud83d\udcc4\", \"\ud83e\udea8\"];\n<mark>var currentEmojiNumber = 0;<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In the <code>shuffleEmojis()<\/code> function, use the <code>currentEmojiNumber <\/code>to pick an emoji out of the <code>emojis <\/code>array.&nbsp;<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function shuffleEmojis() {\n    computerChoice = emojis&#091;<mark>currentEmojiNumber<\/mark>];\n    emojiShuffleElement.textContent = computerChoice;\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>We need to increase the <code>currentEmojiNumber<\/code> if we&#8217;re not on the last index of the <code>emojis<\/code> array and set it to 0 otherwise. <\/strong>We&#8217;ll use an <code>if...else<\/code> conditional statement to do this. Note that the <code>emojis <\/code>array has a <code>length <\/code>property that we can use to find out how big it is and that the last index number is 1 less than the length of the array. Also, note that we can increase the value stored in a variable using the <code>++<\/code> operator, as we do on the <code>currentEmojiNumber<\/code> here.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function shuffleEmojis() {\n    computerChoice = emojis&#091;currentEmojiNumber];\n    emojiShuffleElement.textContent = computerChoice;\n<mark>\n    if (currentEmojiNumber &lt; emojis.length - 1) {\n        currentEmojiNumber++;\n    } else {\n        currentEmojiNumber = 0;\n    }\n<\/mark>\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Remove the call to<code> shuffleEmojis()<\/code>. We&#8217;ll have JavaScript call this function in an interval timer instead.<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>playerChoiceContainer.addEventListener(\"click\", handlePlayerChoice);\n\n<mark><s>shuffleEmojis();&nbsp; \/\/ REMOVE THIS!<\/s><\/mark>\n\n<strong>function<\/strong> <strong>handlePlayerChoice<\/strong>(event) {\n&nbsp; ...\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Use the<code> setInterval()<\/code> function to call the <code>shuffleEmojis()<\/code> function every 150 milliseconds. <\/strong>The <code>setInterval()<\/code>&nbsp;function is provided to us from the browser. It returns a reference to the ID of the running interval timer which we&#8217;ll store in a variable called <code>shuffleIntervalID<\/code>. This ID can be used to stop the interval timer, which we&#8217;ll do in the next step.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var currentEmojiNumber = 0;\n\n<mark>var shuffleIntervalID = setInterval(shuffleEmojis, 150);<\/mark>\n\nvar playerChoiceContainer = document.querySelector(\"#player-choice-container\");<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4 Output<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/ERSDJXUObBCxz2KlG67u9N26_toXJJ_-OLUQAE1BJSAUXxix_dNZJcQ0I9JEJ5ORPDKDF4YNBgyOQBSMcyPbRPmwDSEvGdW8iTBQ_6kykTejfBUC3BlRcx6jTd3gwhVdlMj8rrOd95t4EqBYDrAG8bsBDvQqtjDVVQTgguaxqHN0Ux9oBm1gBPHWs8pTCQ\" alt=\"rock paper scissors step 4\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step5\">Step 5: Pick a random emoji for the computer<\/h2>\n\n\n\n<p>Now that the computer&#8217;s possible choices are shuffling between Rock, Paper, and Scissors, we need to actually pick a random choice for the computer after the player makes their choice.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We&#8217;ll use the <code>clearInterval()<\/code> function to stop <code>shuffleEmojis()<\/code> inside our <code>handlePlayerChoice()<\/code> function. Since the <code>shuffleIntervalID<\/code> points to the interval timer that is running <code>shuffleEmojis()<\/code>, <code>clearInterval()<\/code> will stop that timer.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function handlePlayerChoice(event) {\n    if (!event.target.classList.contains(\"emoji\")) return;\n    playerChoice = event.target.textContent;\n    playerChoiceContainer.innerHTML = `&lt;p class=\"emoji\"&gt;${playerChoice}&lt;\/p&gt;`;\n    <mark>clearInterval(shuffleIntervalID);<\/mark>\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5 Output<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/JUEBvc7ICRZcPY6OvqlmbiHz74RCSjhvDkr_o-IFErThXzS6KSwjozaT-xhiK2yXcXroV8kusik6fi9BFeM2ir2SNpPBtGhS64bdCwHXwUpf96iSPMp-RtXW1KbUM7us5HkLB41VVWbexPTHKW4gMWdmuhSvGSip9k83AL6boZauCI6BhQBZ4UO3PsgQbw\" alt=\"rock paper scissors step 5\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step6\">Step 6: Decide who won the game<\/h2>\n\n\n\n<p>For our last step, we&#8217;ll create a function to see who won the game.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a function called <code>determineGameWinner()<\/code>. This function will hold all the logic to determine who won the game.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><mark>function determineGameWinner() {\n\n}<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create two variables: <code>gameResultMessageElement<\/code> and <code>gameResultMessage<\/code>. We can use <code>document.querySelector()<\/code> to get the HTML element with the ID of <code>game-result-message<\/code> and then&nbsp;the <code>gameResultMessageElement<\/code>. We&#8217;ll make the <code>gameResultMessage <\/code>an empty string for now because we won&#8217;t know the value of this variable until we determine who won.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>playerChoiceContainer.addEventListener(\"click\", handlePlayerChoice);\n\nfunction determineGameWinner() {\n<mark>\n    var gameResultMessageElement = document.querySelector(\"#game-result-message\");\n    var gameResultMessage = \"\";\n<\/mark>\n}\n\nfunction handlePlayerChoice(event) {\n  ...\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We can use a chain of conditional statements to determine if there is a tie, if the player won, or if the computer won. Set the <code>gameResultMessage <\/code>in the body of each conditional statement. Note that we only need to check for a tie and if the player won. If neither of those results occurs, then we can use the <code>else <\/code>clause to state that the computer won. Also, please make sure to add an extra space to the right of the scissors emoji to ensure your program works correctly (there&#8217;s an extra space in the HTML and in our <code>emojis <\/code>array).<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function determineGameWinner() {\n    var gameResultMessageElement = document.querySelector(\"#game-result-message\");\n    var gameResultMessage = \"\";\n<mark>\n    if (playerChoice === computerChoice) {\n        gameResultMessage = \"It's a tie!\";\n        \/\/ Note the extra space in the scissors emoji!\n    } else if (playerChoice === \"\ud83e\udea8\" &amp;&amp; computerChoice === \"\u2702\ufe0f \") {\n        gameResultMessage = \"Player wins!\";\n    } else if (playerChoice === \"\ud83d\udcc4\" &amp;&amp; computerChoice === \"\ud83e\udea8\") {\n        gameResultMessage = \"Player wins!\";\n    } else if (playerChoice === \"\u2702\ufe0f \" &amp;&amp; computerChoice === \"\ud83d\udcc4\") {\n        gameResultMessage = \"Player wins!\";\n    } else {\n        gameResultMessage = \"Computer wins!\";\n    }\n<\/mark>\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The final thing our function needs to do is add our <code>gameResultMessage <\/code>to the page. We do this by making it the <code>textContent<\/code> of the <code>gameResultMessageElement<\/code>. We can also stick the string <em>&#8220;Refresh to play again!&#8221;<\/em> on the end of our <code>gameResultMessage<\/code> so users of our app know how to play another game.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function determineGameWinner() {\n    ...\n\n    if (playerChoice === computerChoice) {\n        gameResultMessage = \"It's a tie!\";\n        \/\/ Note the extra space in the scissors emoji!\n    } else if (playerChoice === \"\ud83e\udea8\" &amp;&amp; computerChoice === \"\u2702\ufe0f \") {\n        gameResultMessage = \"Player wins!\";\n    } else if (playerChoice === \"\ud83d\udcc4\" &amp;&amp; computerChoice === \"\ud83e\udea8\") {\n        gameResultMessage = \"Player wins!\";\n    } else if (playerChoice === \"\u2702\ufe0f \" &amp;&amp; computerChoice === \"\ud83d\udcc4\") {\n        gameResultMessage = \"Player wins!\";\n    } else {\n        gameResultMessage = \"Computer wins!\";\n    }\n\n    <mark>gameResultMessageElement.textContent = gameResultMessage + \" Refresh to play again!\";<\/mark>\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>As the final step, we&#8217;ll call our <code>determineGameWinner()<\/code> function in <code>handlePlayerChoice()<\/code> after all of the other function code has run:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function handlePlayerChoice(event) {\n    if (!event.target.classList.contains(\"emoji\")) return;\n    playerChoice = event.target.textContent;\n    playerChoiceContainer.innerHTML = `&lt;p class=\"emoji\"&gt;${playerChoice}&lt;\/p&gt;`;\n    clearInterval(shuffleIntervalID);\n    <mark>determineGameWinner();<\/mark>\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 6 Output<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/5m3f2xtr7hPgTOFy3YQVkp5DSa6tmIKEXLM0d5F1hCCLR3hAR0XnMQnjtmNPwWv0kSNoqXXgj_Vz6c6u-tjnNf738lahFeFt04MydYp6EkG2VROzp9Nw65w-CkpM46lvN05DFVh5s1ymH-080DJsEjpbWeUe3RMJyehyOn3kRyHcwhP5HqHu4xyZC6n13w\" alt=\"rock paper scissors step 6\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"complete\">Your game is complete!&nbsp;<\/h2>\n\n\n\n<p>Check out the <a href=\"https:\/\/projects.codewizardshq.com\/x_hour_of_code_2022\/javascript-projects\/rock-paper-scissors\/index.html\">finished project<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/6Yvbo3GliY-iWjU6oR6aaY7STs384v1K76-2njJCaEWfaZvov87Jf5ssRj8Z0hxlIN5wuB1frf3J_L-fa7RFgV7oNpgkCRWpENoi1UzXKV2v-8Ud7H2pxB5uzBhY84mq3zVZemIEcPXcSSO-DnFdW1ioTwMXqAMr1t_zICEkzNjF8eH0HQ98piBRVl0_5A\" alt=\"rock paper scissors complete game\"\/><\/figure>\n\n\n\n<p><strong>Download the <\/strong><a href=\"https:\/\/drive.google.com\/drive\/folders\/1vBQ284j7TKPOEH4PKeTzixRvmw5SYFsR?usp=share_link\"><strong>project files<\/strong><\/a><strong> and open <\/strong>app.js<strong> to view the completed project code.<\/strong><\/p>\n\n\n\n<p>Add this fun game to your portfolio and show it off to family and friends. You can even customize the code to be your own version of Rock, Paper, Scissors with new rules and design.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"download\"><strong>Download JavaScript Projects Source Code<\/strong><\/h3>\n\n\n\n<p>If you want to get the code behind 7 different JavaScript projects, download the full source code for free. You can use this code as an example to add to or inspire new projects. Enter your email below:<\/p>\n\n\n\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>If you want to code more websites and games in JavaScript, join CodeWizardsHQ\u2019s live <a href=\"\/\">coding classes for kids<\/a>.<\/strong> It\u2019s the most fun and effective way for kids to learn JavaScript and other real-world languages.&nbsp;<\/p>\n\n\n\n<p>Students in all of our <a href=\"\/coding-programs-for-kids\/\">core programming tracks<\/a> study JavaScript because of its importance in web development and beyond. They work with a live, expert instructor who supports them every step of the way. Classes are engaging and you\u2019ll build a portfolio of websites, games, and apps as you learn.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Is rock, paper, scissors more about skill or luck? Everyone has their own theory, but it&#8217;s one of those games that we all love to play when we\u2019re bored. The logic is relatively simple, so it&#8217;s an easy game for beginners to turn into code too. You can replicate this game in any coding language, [&hellip;]<\/p>\n","protected":false},"author":336,"featured_media":53399,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"om_disable_all_campaigns":false,"inline_featured_image":false,"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[10809,4758],"tags":[10739,10814],"class_list":["post-53373","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-activities","category-learn-coding","tag-javascript","tag-tutorials"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v26.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>JavaScript Tutorial for Kids: Rock, Paper, Scissors | CodeWizardsHQ<\/title>\n<meta name=\"description\" content=\"JavaScript tutorial for kids to code the game Rock, Paper, Scissors. Learn JavaScript with this easy and fun tutorial with source code!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Tutorial for Kids: Rock, Paper, Scissors\" \/>\n<meta property=\"og:description\" content=\"JavaScript tutorial for kids to code the game Rock, Paper, Scissors. Learn JavaScript with this easy and fun tutorial with source code!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/\" \/>\n<meta property=\"og:site_name\" content=\"CodeWizardsHQ\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codewizardshq\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-11T07:11:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-26T11:34:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-tutorial-social-banner.png\" \/>\n\t<meta property=\"og:image:width\" content=\"620\" \/>\n\t<meta property=\"og:image:height\" content=\"323\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Daniel Schroeder\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codewizardshq\" \/>\n<meta name=\"twitter:site\" content=\"@codewizardshq\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel Schroeder\" \/>\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\">{\n\t    \"@context\": \"https:\/\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"Article\",\n\t            \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Daniel Schroeder\",\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/#\/schema\/person\/8f483c66dd46a2d608d50adde5c5c0f2\"\n\t            },\n\t            \"headline\": \"JavaScript Tutorial for Kids: Rock, Paper, Scissors\",\n\t            \"datePublished\": \"2022-11-11T07:11:01+00:00\",\n\t            \"dateModified\": \"2025-08-26T11:34:19+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/\"\n\t            },\n\t            \"wordCount\": 1963,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-banner.png\",\n\t            \"keywords\": [\n\t                \"JavaScript\",\n\t                \"tutorials\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Activities\",\n\t                \"Learn Coding\"\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/\",\n\t            \"url\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/\",\n\t            \"name\": \"JavaScript Tutorial for Kids: Rock, Paper, Scissors | CodeWizardsHQ\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-banner.png\",\n\t            \"datePublished\": \"2022-11-11T07:11:01+00:00\",\n\t            \"dateModified\": \"2025-08-26T11:34:19+00:00\",\n\t            \"description\": \"JavaScript tutorial for kids to code the game Rock, Paper, Scissors. Learn JavaScript with this easy and fun tutorial with source code!\",\n\t            \"breadcrumb\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#breadcrumb\"\n\t            },\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#primaryimage\",\n\t            \"url\": \"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-banner.png\",\n\t            \"contentUrl\": \"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-banner.png\",\n\t            \"width\": 1600,\n\t            \"height\": 395,\n\t            \"caption\": \"RPS javascript banner\"\n\t        },\n\t        {\n\t            \"@type\": \"BreadcrumbList\",\n\t            \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#breadcrumb\",\n\t            \"itemListElement\": [\n\t                {\n\t                    \"@type\": \"ListItem\",\n\t                    \"position\": 1,\n\t                    \"name\": \"Home\",\n\t                    \"item\": \"https:\/\/www.codewizardshq.com\/\"\n\t                },\n\t                {\n\t                    \"@type\": \"ListItem\",\n\t                    \"position\": 2,\n\t                    \"name\": \"JavaScript Tutorial for Kids: Rock, Paper, Scissors\"\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\/\/www.codewizardshq.com\/#website\",\n\t            \"url\": \"https:\/\/www.codewizardshq.com\/\",\n\t            \"name\": \"CodeWizardsHQ\",\n\t            \"description\": \"The leading online coding academy for kids and teens ages 8-18\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\/\/www.codewizardshq.com\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\/\/www.codewizardshq.com\/#organization\",\n\t            \"name\": \"CodeWizardsHQ\",\n\t            \"url\": \"https:\/\/www.codewizardshq.com\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/#\/schema\/logo\/image\/\",\n\t                \"url\": \"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2016\/08\/blueVertical@2x-e1572141901928.png\",\n\t                \"contentUrl\": \"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2016\/08\/blueVertical@2x-e1572141901928.png\",\n\t                \"width\": 150,\n\t                \"height\": 108,\n\t                \"caption\": \"CodeWizardsHQ\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/#\/schema\/logo\/image\/\"\n\t            },\n\t            \"sameAs\": [\n\t                \"https:\/\/www.facebook.com\/codewizardshq\/\",\n\t                \"https:\/\/x.com\/codewizardshq\",\n\t                \"https:\/\/www.instagram.com\/codewizardshq\/\",\n\t                \"https:\/\/www.linkedin.com\/company\/codewizardshq\",\n\t                \"https:\/\/www.pinterest.com\/codewizardshq\/\",\n\t                \"https:\/\/www.youtube.com\/channel\/UC4NM0jfN0LI8_vWtiwLqgGw\"\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\/\/www.codewizardshq.com\/#\/schema\/person\/8f483c66dd46a2d608d50adde5c5c0f2\",\n\t            \"name\": \"Daniel Schroeder\",\n\t            \"image\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/#\/schema\/person\/image\/\",\n\t                \"url\": \"https:\/\/secure.gravatar.com\/avatar\/8a310902521019d3ffab08d7e0833119829be11c3593564c614e825a12882b09?s=96&d=mm&r=g\",\n\t                \"contentUrl\": \"https:\/\/secure.gravatar.com\/avatar\/8a310902521019d3ffab08d7e0833119829be11c3593564c614e825a12882b09?s=96&d=mm&r=g\",\n\t                \"caption\": \"Daniel Schroeder\"\n\t            },\n\t            \"description\": \"Daniel has been a curriculum developer, instructor, forum moderator, and all-around problem-solver at CodeWizardsHQ since mid-2020. He's passionate about programming and constantly strives to improve educational outcomes by creating practical, fun assignments and pushing students to pursue coding as a creative endeavor.\",\n\t            \"url\": \"https:\/\/www.codewizardshq.com\/author\/danielj\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"JavaScript Tutorial for Kids: Rock, Paper, Scissors | CodeWizardsHQ","description":"JavaScript tutorial for kids to code the game Rock, Paper, Scissors. Learn JavaScript with this easy and fun tutorial with source code!","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:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Tutorial for Kids: Rock, Paper, Scissors","og_description":"JavaScript tutorial for kids to code the game Rock, Paper, Scissors. Learn JavaScript with this easy and fun tutorial with source code!","og_url":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/","og_site_name":"CodeWizardsHQ","article_publisher":"https:\/\/www.facebook.com\/codewizardshq\/","article_published_time":"2022-11-11T07:11:01+00:00","article_modified_time":"2025-08-26T11:34:19+00:00","og_image":[{"width":620,"height":323,"url":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-tutorial-social-banner.png","type":"image\/png"}],"author":"Daniel Schroeder","twitter_card":"summary_large_image","twitter_creator":"@codewizardshq","twitter_site":"@codewizardshq","twitter_misc":{"Written by":"Daniel Schroeder","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#article","isPartOf":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/"},"author":{"name":"Daniel Schroeder","@id":"https:\/\/www.codewizardshq.com\/#\/schema\/person\/8f483c66dd46a2d608d50adde5c5c0f2"},"headline":"JavaScript Tutorial for Kids: Rock, Paper, Scissors","datePublished":"2022-11-11T07:11:01+00:00","dateModified":"2025-08-26T11:34:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/"},"wordCount":1963,"publisher":{"@id":"https:\/\/www.codewizardshq.com\/#organization"},"image":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-banner.png","keywords":["JavaScript","tutorials"],"articleSection":["Activities","Learn Coding"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/","url":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/","name":"JavaScript Tutorial for Kids: Rock, Paper, Scissors | CodeWizardsHQ","isPartOf":{"@id":"https:\/\/www.codewizardshq.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#primaryimage"},"image":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-banner.png","datePublished":"2022-11-11T07:11:01+00:00","dateModified":"2025-08-26T11:34:19+00:00","description":"JavaScript tutorial for kids to code the game Rock, Paper, Scissors. Learn JavaScript with this easy and fun tutorial with source code!","breadcrumb":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#primaryimage","url":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-banner.png","contentUrl":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-banner.png","width":1600,"height":395,"caption":"RPS javascript banner"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-rock-paper-scissors\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codewizardshq.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript Tutorial for Kids: Rock, Paper, Scissors"}]},{"@type":"WebSite","@id":"https:\/\/www.codewizardshq.com\/#website","url":"https:\/\/www.codewizardshq.com\/","name":"CodeWizardsHQ","description":"The leading online coding academy for kids and teens ages 8-18","publisher":{"@id":"https:\/\/www.codewizardshq.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codewizardshq.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codewizardshq.com\/#organization","name":"CodeWizardsHQ","url":"https:\/\/www.codewizardshq.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codewizardshq.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2016\/08\/blueVertical@2x-e1572141901928.png","contentUrl":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2016\/08\/blueVertical@2x-e1572141901928.png","width":150,"height":108,"caption":"CodeWizardsHQ"},"image":{"@id":"https:\/\/www.codewizardshq.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codewizardshq\/","https:\/\/x.com\/codewizardshq","https:\/\/www.instagram.com\/codewizardshq\/","https:\/\/www.linkedin.com\/company\/codewizardshq","https:\/\/www.pinterest.com\/codewizardshq\/","https:\/\/www.youtube.com\/channel\/UC4NM0jfN0LI8_vWtiwLqgGw"]},{"@type":"Person","@id":"https:\/\/www.codewizardshq.com\/#\/schema\/person\/8f483c66dd46a2d608d50adde5c5c0f2","name":"Daniel Schroeder","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codewizardshq.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8a310902521019d3ffab08d7e0833119829be11c3593564c614e825a12882b09?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8a310902521019d3ffab08d7e0833119829be11c3593564c614e825a12882b09?s=96&d=mm&r=g","caption":"Daniel Schroeder"},"description":"Daniel has been a curriculum developer, instructor, forum moderator, and all-around problem-solver at CodeWizardsHQ since mid-2020. He's passionate about programming and constantly strives to improve educational outcomes by creating practical, fun assignments and pushing students to pursue coding as a creative endeavor.","url":"https:\/\/www.codewizardshq.com\/author\/danielj\/"}]}},"modified_by":"Dima","featured_image_src":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-banner-600x395.png","featured_image_src_square":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/RPS-javascript-banner-600x395.png","author_info":{"display_name":"Daniel Schroeder","author_link":"https:\/\/www.codewizardshq.com\/author\/danielj\/"},"_links":{"self":[{"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/posts\/53373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/users\/336"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/comments?post=53373"}],"version-history":[{"count":1,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/posts\/53373\/revisions"}],"predecessor-version":[{"id":71709,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/posts\/53373\/revisions\/71709"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/media\/53399"}],"wp:attachment":[{"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/media?parent=53373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/categories?post=53373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/tags?post=53373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}