{"id":53334,"date":"2022-12-05T08:00:00","date_gmt":"2022-12-05T14:00:00","guid":{"rendered":"https:\/\/www.codewizardshq.com\/?p=53334"},"modified":"2025-08-29T03:34:49","modified_gmt":"2025-08-29T09:34:49","slug":"javascript-tutorial-for-kids-disappearing-snowman","status":"publish","type":"post","link":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/","title":{"rendered":"JavaScript Tutorial for Kids: Disappearing Snowman"},"content":{"rendered":"\n<p>Guess the right word before your snowman melts!&nbsp;<\/p>\n\n\n\n<p><strong>We\u2019ve created this tutorial just in time for the holidays. Code a fun word game that you can share with family and friends.&nbsp;<\/strong><\/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>This Christmas-themed guessing game uses simple JavaScript code to power the game functions. Try coding this game following the tutorial and then customize it to make it your own.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Complete this JavaScript tutorial to make your own Disappearing Snowman Game.<\/strong><\/h3>\n\n\n\n<p>Play the completed <a href=\"https:\/\/projects.codewizardshq.com\/x_hour_of_code_2022\/javascript-projects\/disappearing-snowman\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">Disappearing Snowman Game<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/okTutxglPKN5d2N4woehf9U6m7Rnlu2ffECj9UwOc2QRywzvniRixqPj1eQCdOb6ECnKKmk09xe3ktd9PBlnbFDHRhm2AYw5FVRB0_R_rQLHfmoEiRNFg86-Wt-9jkiKrnf4H9HgDcFet21DPMjpjfXqwICcl4YKg4hYrijZ4mp0e6eXhGd4jZLHrZPQpA\" alt=\"Disappearing snowman javascript game\"\/><\/figure>\n\n\n\n<p><\/p>\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-Z1LNGWh 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: Fade keyboard keys on click<\/a><\/li>\n\n\n\n<li><a href=\"#step2\">Step 2: Check for a match when clicking a keyboard key<\/a><\/li>\n\n\n\n<li><a href=\"#step3\">Step 3: Remove a snowman part when there&#8217;s no match for a clicked keyboard key<\/a><\/li>\n\n\n\n<li><a href=\"#step4\">Step 4: Check if the player loses<\/a><\/li>\n\n\n\n<li><a href=\"#step5\">Step 5: Check if the player wins<\/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<p><\/p>\n\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\/\" target=\"_blank\" rel=\"noreferrer noopener\">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\/10JjvIR2qwKmgDZ9z5G0cHPjbiGwOx3wb?usp=share_link\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Download the base files<\/strong><\/a><strong> and open the <code>app.js<\/code> file.<\/strong> 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 file<\/code> 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\/disappearing-snowman\/starter-files<\/code> directory.<\/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 app.js 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\">This tutorial is for beginner JavaScript programmers ages 8+. It assumes you understand basic HTML\/CSS and JavaScript. Let&#8217;s get started!<\/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: Fade keyboard keys on click<\/h2>\n\n\n\n<p>When someone uses our app, they&#8217;ll try to guess the hidden word one letter at a time by clicking the keyboard on the page with their mouse. In this step, we&#8217;ll fade out each letter they click and ensure that no more logic runs on a faded-out letter.&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In the <code>styles.css<\/code> file there&#8217;s a CSS class to make a keyboard key look faded out called <code>selected<\/code>.<\/strong> We&#8217;ll attach this class to whatever keyboard key the user clicks using JavaScript. You don&#8217;t have to type anything in the CSS file, this is just provided as a reference so you know <em>why<\/em> attaching this class to an HTML element makes it look faded out. <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* Added by JavaScript *\/\n\n.hidden {\n    display: none;\n}\n\n.selected {\n    opacity: 0.3;\n}<\/code><\/pre>\n\n\n\n<p>Navigate back to your <code>app.js<\/code> file to add the selected class to any key the user clicks.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>First, create a variable called <code>keyboardContainer<\/code><\/strong><\/li>\n\n\n\n<li><strong>Use the <code>document.querySelector() <\/code>function to reference the element with the ID of <code>keyboard-container<\/code> <\/strong>and store it in the <code>keyboardContainer <\/code>variable<\/li>\n\n\n\n<li><strong>Then, we need to run code whenever an element in the <code>keyboardContainer<\/code> is clicked.<\/strong> We can use the <code>addEventListener()<\/code> function to ensure a function called <code>handleKeyboardClick()<\/code> (which we&#8217;ll define in just a minute) will run whenever a user clicks inside the <code>keyboardContainer<\/code>. The <code>click<\/code> event is triggered by clicking your mouse anywhere inside the <code>keyboardContainer<\/code> HTML element.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var words = &#091;\"APPLE\", \"PANCAKES\", \"COMPUTER\", \"PARIS\", \"MICROPHONE\", \"PASTRY\"];\nvar randomWord = getRandomWord(words);\n<mark>\nvar keyboardContainer = document.querySelector(\"#keyboard-container\");\nkeyboardContainer.addEventListener(\"click\", handleKeyboardClick);<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Create the function <code>handleKeyboardClick()<\/code> and define a single parameter called <\/strong><code><strong>event<\/strong> <\/code>that will be passed to this function whenever the <code>keyboardContainer <\/code>is clicked.<\/li>\n\n\n\n<li><strong>Whenever our <code>keyboardContainer <\/code>is clicked, we&#8217;ll run the <code>handleKeyboardClick()<\/code> function.<\/strong>&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>keyboardContainer.addEventListener(\"click\", handleKeyboardClick);\n\ngenerateHiddenWord(randomWord);\n<mark>\nfunction handleKeyboardClick(event) {\n\n}<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Create a variable called <code>clickedElement<\/code>. <\/strong>We can get information about the element that was clicked by using the <code>target<\/code> property. We&#8217;ll store the element that was clicked in the variable.<\/li>\n\n\n\n<li><strong>Anytime a user clicks inside the <code>keyboardContainer <\/code>element our click event listener will fire. <\/strong>But, we only want to continue if they click on a letter. <strong>Check if the <code>clickedElement <\/code>does not (<code>!<\/code>) contain the <code>letter <\/code>class or if (<code>||<\/code>) contains the <code>selected<\/code> class (which we&#8217;ll add next).<\/strong> If either of those conditions is true, we&#8217;ll use the <code>return<\/code> keyword to immediately exit the function.&nbsp;<\/li>\n\n\n\n<li><strong>Finally, we&#8217;ll add the <code>selected <\/code>class to our <\/strong><code><strong>clickedElement<\/strong> <\/code>to ensure the CSS styles are applied to make it fade out a bit.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function handleKeyboardClick(event) {\n<mark>\n    var clickedElement = event.target;\n\n    if (!clickedElement.classList.contains(\"letter\") || clickedElement.classList.contains(\"selected\")) return;\n\n    clickedElement.classList.add(\"selected\");\n<\/mark>\n}<\/code><\/pre>\n\n\n\n<p style=\"background: none repeat scroll 0 0 #ececec; clear: both; margin-bottom: 18px; overflow: hidden; border: 1px solid #eeeeee; padding: 13px;\"><strong><i> Hint:<\/i><\/strong><i> Test this out by clicking a few of the keys on the HTML page. They should fade out as you click them!<\/i><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1 Output: <\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/yCSueY6J9oQ0H-2OUvA8lJL_bW5qPLKTb2fvlcXs4L6o-2aGBPAHogvge_IdCuq4Ei5J3gDKGo6SFM6qYqjW3ArFkxtKUvBB2xenteQ5CAv9xA0UXPzSEJUl8NBS61nhRwY0wmv7Peg_rC7B3HAhky3IYLQp4xi573l3hAirWEcvFm5dZJcDZZJUU0TXkA\" alt=\"Javascript tutorial step 1\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step2\">Step 2: Check for a match when clicking a keyboard key<\/h2>\n\n\n\n<p>In this step, we&#8217;ll check to see if the keyboard key a user clicks matches any of the letters in the hidden word. If so, we&#8217;ll show all of the matching letters in the hidden word.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>First, let&#8217;s define a function called <code>checkForMatch()<\/code>.<\/strong> This function will take the <code>clickedLetter <\/code>as a parameter and will check to see if it matches any of the hidden letters.<\/li>\n\n\n\n<li><strong>Create a variable called <code>hiddenLetterElements <\/code>where we\u2019ll store references to the hidden letters. <\/strong>We&#8217;ll need to know all of the hidden letters on the page in order to compare them with the <code>clickedLetter <\/code>parameter. To get them, use <code>document.querySelectorAll() <\/code>and select all elements with the class <code>hidden<\/code>. The <code>querySelectorAll()<\/code> method returns an array-like object that represents any HTML elements with the selector passed into the parentheses.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>generateHiddenWord(randomWord);\n<mark>\nfunction checkForMatch(clickedLetter) {\n  var hiddenLetterElements = document.querySelectorAll(\".hidden\");\n}\n<\/mark>\nfunction handleKeyboardClick(event) {\n  ...\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Once we have all of the <code>hiddenLetterElements<\/code>, we can use a <code>for...of<\/code> loop to loop through the hidden letters one at a time. <\/strong>We\u2019ll compare them with the <code>clickedLetter <\/code>that was passed in as a parameter to the function.<\/li>\n\n\n\n<li>I<strong>n the <code>for...of<\/code> loop, create a variable called&nbsp;<code>hiddenLetter <\/code>and get the <code>textContent <\/code>of the <code>hiddenLetterElement<\/code>.<\/strong>&nbsp;<\/li>\n\n\n\n<li><strong>Then, use a conditional statement to compare the <code>hiddenLetter <\/code>with our clickedLetter parameter and see if they are the same.<\/strong> The <code>===<\/code> operator ensures that both items it compares are equal.<\/li>\n\n\n\n<li>The last thing we need to do in our <code>checkForMatch() <\/code>function is to remove the <code>hidden <\/code>class from any <code>hiddenLetterElement <\/code>whose letter matches the <code>clickedLetter<\/code>. The <code>remove()<\/code> method of the <code>classList <\/code>object allows us to remove a class from an HTML element.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function checkForMatch(clickedLetter) {\n    var hiddenLetterElements = document.querySelectorAll(\".hidden\");\n<mark>\n    for (var hiddenLetterElement of hiddenLetterElements) {\n        var hiddenLetter = hiddenLetterElement.textContent;\n        if (hiddenLetter === clickedLetter) {\n            hiddenLetterElement.classList.remove(\"hidden\");\n        }\n    }<\/mark>\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Finally, back in our <code>handleKeyboardClick()<\/code> function, create a <code>clickedLetter <\/code>variable to store the <code>textContent <\/code>of the <code>clickedElement<\/code>.<\/strong><\/li>\n\n\n\n<li><strong>Then we\u2019ll pass this variable to our new <code>checkForMatch()<\/code> function.<\/strong> This ensures that whenever a user clicks a keyboard letter, <code>handleKeyboardClick()<\/code> will check for a match with that letter and all of the hidden letters.&nbsp;<\/li>\n\n\n\n<li><strong>Run your program and try clicking a few of the keyboard letters. <\/strong>You should see the ones that match the hidden letters show up on the page!<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function handleKeyboardClick(event) {\n    var clickedElement = event.target;\n   \n    if (!clickedElement.classList.contains(\"letter\") || clickedElement.classList.contains(\"selected\")) return;\n\n    clickedElement.classList.add(\"selected\");\n<mark>\n    var clickedLetter = clickedElement.textContent;\n    checkForMatch(clickedLetter);\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:\/\/lh4.googleusercontent.com\/yUknPnvuzE2E0q9za1U_irnp96_OIe5I4dz0I_tLNPRYtJ-pZwvKS-3x4fo8pGg7HkKNd_o-8nn8-VZxEiR7WrLpe6BFkqK9_99wzJRMc1pGjbXblnN_0LAe82P4DSUVRrIxi9C8ujt05o2o2WnMSuxzZipfUYYZOeqv9-xkwzB2TbPhfNue3HohcGRG7w\" alt=\"Javascript tutorial step 2\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step3\">Step 3: Remove a snowman part when there&#8217;s no match for a clicked keyboard key<\/h2>\n\n\n\n<p>Now that we can tell if a user found a match or not, we need to remove a snowman part whenever there isn&#8217;t a match. This makes it seem like the snowman is melting if you guess a letter incorrectly!<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Our snowman is made up of a few parts that are distinguished by CSS classes. <\/strong>The main parts have the classes hat, face, scarf, hands, body-top, body-middle, and body-bottom. You can see these parts if you view the HTML in <code>index.html<\/code>.&nbsp;<\/li>\n<\/ul>\n\n\n\n<p><\/p>\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\/snowman-html-css.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"587\" src=\"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/snowman-html-css-1024x587.jpg\" alt=\"snowman html css\" class=\"wp-image-53859\" srcset=\"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/snowman-html-css-1024x587.jpg 1024w, https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/snowman-html-css-300x172.jpg 300w, https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/snowman-html-css-768x440.jpg 768w, https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/snowman-html-css-1536x880.jpg 1536w, https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/snowman-html-css.jpg 1935w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<p><strong><em>index.html <\/em><\/strong><em>(no changes here, just shown for context)<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;section id=\"snowman-container\"&gt;\n    &lt;img class=\"hat\" src=\"images\/hat.png\" \/&gt;\n    &lt;img class=\"face nose\" src=\"images\/nose.png\" \/&gt;\n    &lt;img class=\"face eyes\" src=\"images\/eyes.png\" \/&gt;\n    &lt;img class=\"face mouth\" src=\"images\/mouth.png\" \/&gt;\n    &lt;img class=\"scarf\" src=\"images\/scarf.png\" \/&gt;\n    &lt;img class=\"hands left-hand\" src=\"images\/left-hand.png\" \/&gt;\n    &lt;img class=\"hands right-hand\" src=\"images\/right-hand.png\" \/&gt;\n    &lt;img class=\"body-top\" src=\"images\/body-top.png\" \/&gt;\n    &lt;img class=\"body-middle\" src=\"images\/body-middle.png\" \/&gt;\n    &lt;img class=\"body-bottom\" src=\"images\/body-bottom.png\" \/&gt;\n&lt;\/section&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In app.js, create an array called <code>snowmanParts <\/code>and store each of the classnames. <\/strong>Order them from top (hat) to bottom (body-bottom). Note that each snowman part starts with a dot (<code>.<\/code>). This is a CSS notation that indicates each string represents a CSS class, and we&#8217;ll use the strings in the <code>snowmanParts <\/code>array to query the correct HTML element by its class name.&nbsp;<\/li>\n<\/ul>\n\n\n\n<p><strong><em>app.js<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var words = &#091;\"APPLE\", \"PANCAKES\", \"COMPUTER\", \"PARIS\", \"MICROPHONE\", \"PASTRY\"];\nvar randomWord = getRandomWord(words);\nvar keyboardContainer = document.querySelector(\"#keyboard-container\");\n<mark>var snowmanParts = &#091;\".hat\", \".face\", \".scarf\", \".hands\", \".body-top\", \".body-middle\", \".body-bottom\"];<\/mark>\n\nkeyboardContainer.addEventListener(\"click\", handleKeyboardClick);<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a function called <code>removeSnowmanPart()<\/code>. This function will remove a single snowman part associated with those main classes each time the user guesses a letter that isn&#8217;t one of the hidden letters. <\/li>\n\n\n\n<li><strong>To&nbsp;remove the snowman parts from top-to-bottom, we need to remove the first item from the array each time <code>removeSnowmanPart()<\/code> is called.<\/strong> To remove the first item from an array, you use the <code>Array.shift() <\/code>method. We&#8217;ll store the removed item (which represents a CSS class) in a variable called <code>snowmanPart<\/code>.<\/li>\n\n\n\n<li><strong>Next, create a variable called <code>partsToRemove <\/code>to store these parts. <\/strong>Get the HTML element that represents the <code>snowmanPart<\/code> using <code>document.querySelectorAll()<\/code>. Remember, <code>snowmanPart <\/code>is a CSS selector (it starts with a dot) and <code>querySelectorAll()<\/code> will give us an array-like object of all HTML elements matching the selector we give it.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><mark>function removeSnowmanPart() {\n    var snowmanPart = snowmanParts.shift();\n    var partsToRemove = document.querySelectorAll(snowmanPart);\n}<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>The final step of our function definition will be to loop through all of the <code>partsToRemove <\/code>and remove each part from the HTML document.<\/strong> To do this, we can create a <code>for...of<\/code> loop and then call the <code>element.remove()<\/code> function on each <code>partToRemove<\/code>. The <code>element.remove()<\/code> function removes an HTML element from the page.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function removeSnowmanPart() {\n    var snowmanPart = snowmanParts.shift();\n    var partsToRemove = document.querySelectorAll(snowmanPart);\n\n    for (var partToRemove of partsToRemove) {\n        partToRemove.remove();\n    }\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Before we can determine if the user guessed incorrectly, we&#8217;ll need to edit the <code>checkForMatch()<\/code> function to return a boolean value: <code>true <\/code>or <code>false<\/code>. <\/strong>We start <code>hasMatch<\/code> as <code>false<\/code>, and only change it to <code>true <\/code>if there is a match when we are comparing the <code>clickedLetter<\/code> to the <code>hiddenLetter<\/code> in the <code>for...of <\/code>loop.<\/li>\n\n\n\n<li><strong>The <code>removeSnowmanPart()<\/code> function should be called only when the user doesn&#8217;t guess the correct hidden letter in our <code>handleKeyboardClick()<\/code> function. <\/strong>The <code>checkForMatch()<\/code> function will return <code>true <\/code>if we found a match, and <code>false <\/code>otherwise.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function checkForMatch(clickedLetter) {\n    var hiddenLetterElements = document.querySelectorAll(\".hidden\");\n    <mark>var hasMatch = false;<\/mark>\n    for (var hiddenLetterElement of hiddenLetterElements) {\n        var hiddenLetter = hiddenLetterElement.textContent;\n        if (hiddenLetter === clickedLetter) {\n            hiddenLetterElement.classList.remove(\"hidden\");\n            <mark>hasMatch = true;<\/mark>\n        }\n    }\n\n    <mark>return hasMatch;<\/mark>\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Finally, in our <code>handleKeyboardClick()<\/code> function, we can create a variable called <code>hasMatch <\/code>and store the returned value from the <code>checkForMatch()<\/code> function. <\/strong>Remember, this variable is either the boolean value <code>true <\/code>or <code>false<\/code>.&nbsp;<\/li>\n\n\n\n<li><strong>We can then use that value in a conditional statement and call the <code>removeSnowmanPart()<\/code> function if there was no match. <\/strong>The ! operator means &#8220;not&#8221;, so we&#8217;re saying &#8220;If there&#8217;s no match, remove a snowman part&#8221; in this code sample.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function handleKeyboardClick(event) {\n    var clickedElement = event.target;\n\n    if (!clickedElement.classList.contains(\"letter\") || clickedElement.classList.contains(\"selected\")) return;\n\n    clickedElement.classList.add(\"selected\");\n\n    var clickedLetter = clickedElement.textContent;\n    <mark>var hasMatch = checkForMatch(clickedLetter);\n\n    if (!hasMatch) {\n        removeSnowmanPart();\n    }<\/mark>\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:\/\/lh5.googleusercontent.com\/WoMNXITEvPgVkgo6IkLY1KJWF1oTAPvxNCgUDsY7LvCM0XCc9B_xrSsKjrpyvwGR6v3_uuWhG3v9x1XE-JC_T_PfOtrRNsrVBApbIZ_qaE8z0rA__gUyBLOeE4QqlFKFiPbRwbYu49R75l6w3IOP_CTJrwQjSfV6KyRKPZviRRFTvp0aZxMTnNBbC6vk9g\" alt=\"Javascript tutorial step 4\"\/><\/figure>\n\n\n\n<p><em>Recommended: <a href=\"https:\/\/www.codewizardshq.com\/javascript-classes-for-kids\/\"><strong>JavaScript Classes for Kids<\/strong><\/a><\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step4\">Step 4: Check if the player loses<\/h2>\n\n\n\n<p>A game is no fun without winners and losers! In this step, we&#8217;ll show a message if the user guesses incorrectly too many times and the snowman melts before they guess the hidden word.&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>We&#8217;ll create a function called <code>checkForLoser()<\/code> to check if the snowman has melted and the user loses.<\/strong> You lose when the snowman has melted, and in our program we&#8217;re removing a part from the <code>snowmanParts <\/code>array every time a user guesses a letter that isn&#8217;t in the hidden word. The snowman will be &#8220;melted&#8221; when there are no parts left in the <code>snowmanParts <\/code>array. We can check if there are no parts left in the <code>snowmanParts<\/code> array using a conditional statement and by comparing the length property of the <code>snowmanParts <\/code>array to 0.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><mark>function checkForLoser() {\n    if (snowmanParts.length === 0) {\n\n    }\n}<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>In our conditional statement, we&#8217;ll add two messages to the page.<\/strong> The first will replace all the HTML in the <code>snowman-container <\/code>element with the text <strong><em>&#8220;You lost, game over!&#8221;<\/em><\/strong>. The second will replace all of the HTML in the <code>keyboardContainer <\/code>with the text &#8220;<strong><em>The word was: [RANDOM WORD]&#8221;<\/em><\/strong>. The <strong><em>RANDOM WORD <\/em><\/strong>will be whatever value is stored in the <code>randomWord <\/code>variable. Note that we can query and adjust the <code>snowman-container<\/code> on a single line since we don&#8217;t already have a reference to that HTML element stored in a variable.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function checkForLoser() {\n    if (snowmanParts.length === 0) {\n        <mark>document.querySelector(\"#snowman-container\").innerHTML = \"&lt;h2&gt;You lost, game over!&lt;\/h2&gt;\";\n        keyboardContainer.innerHTML = `&lt;h2&gt;The word was: ${randomWord}&lt;\/h2&gt;`; <\/mark>\n\n    }\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Now that our <code>checkForLoser()<\/code> function is working, we need to call it whenever the user clicks a key on the keyboard and the letter doesn&#8217;t match a letter in the hidden word.<\/strong> We&#8217;ve already got a conditional statement in the <code>handleKeyboardClick()<\/code> function to check if the user didn&#8217;t guess a matching letter, so we can call our <code>checkForLoser()<\/code> function after the <code>removeSnowmanPart()<\/code> function. This will ensure that we only check if the snowman is melted <em>after<\/em> removing a snowman part.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>function<\/strong> <strong>handleKeyboardClick<\/strong>(event) {\n&nbsp; &nbsp; <strong>var<\/strong> clickedElement = event.target;\n\n&nbsp; &nbsp; <strong>if<\/strong> (!clickedElement.classList.contains(\"letter\") || clickedElement.classList.contains(\"selected\")) <strong>return<\/strong>;\n\n&nbsp; &nbsp; clickedElement.classList.add(\"selected\");\n\n&nbsp; &nbsp; <strong>var<\/strong> clickedLetter = clickedElement.textContent;\n&nbsp; &nbsp; <strong>var<\/strong> hasMatch = checkForMatch(clickedLetter);\n\n&nbsp; &nbsp; <strong>if<\/strong> (!hasMatch) {\n&nbsp; &nbsp; &nbsp; &nbsp; removeSnowmanPart();\n&nbsp; &nbsp; &nbsp; &nbsp; <mark>checkForLoser();<\/mark>\n&nbsp; &nbsp; }\n}<\/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:\/\/lh6.googleusercontent.com\/oYS9fAkv64ZpDZQAkrts36XCp8iUiL8pawtEsNn7-uXpbNSLJAqgyGVKXUA-x9jVFeMMuTrVi_pvz3AJjUH4r0uHNDrpvfzrudrDrWX21ChMRuXPND4o70Oo00QTOOZjWqUmCL5pe-YYZgzvus0plOykTZm1hmBdvW6hCVgaxJIL9WKp5Bv5s86pPeurOQ\" alt=\"Javascript tutorial step 4\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step5\">Step 5: Check if the player wins<\/h2>\n\n\n\n<p>For our final step, we&#8217;ll show a message if the player guesses the hidden word without melting the snowman!<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>First, we&#8217;ll create a function called <code>checkForWinner()<\/code>. <\/strong>A user wins when there are no more hidden letters, so this function&#8217;s job will be to show a winning message when there are no more hidden letters on the page.<\/li>\n\n\n\n<li>Create a variable called <code>hiddenLetterElements<\/code>. To check for hidden letters, we first need a reference to all of the elements on the page with the class <code>hidden<\/code>. We can use <code>document.querySelectorAll()<\/code> to get an array of all the HTML elements with the class <code>hidden<\/code> and store them in <code>hiddenLetterElements<\/code>.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><mark>function checkForWinner() {\n    var hiddenLetterElements = document.querySelectorAll(\".hidden\");\n}<\/mark><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>We can check the <code>length <\/code>property of the <code>hiddenLetterElements <\/code>array to see if there are any more HTML elements with the <code>hidden <\/code>class on the page. <\/strong>If the <code>length<\/code> property is 0, there are no more hidden letters on the page.<\/li>\n\n\n\n<li><strong>When there are no more hidden elements, the user wins!<\/strong> We can use the <code>innerHTML<\/code> property of the <code>keyboardContainer<\/code> to put a winning message on the page in place of the keyboard.<br><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function checkForWinner() {\n    var hiddenLetterElements = document.querySelectorAll(\".hidden\");\n    <mark>if (hiddenLetterElements.length === 0) {\n        keyboardContainer.innerHTML = \"&lt;h2&gt;You win!&lt;\/h2&gt;\";\n    }<\/mark>\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Finally, we need to call our <code>checkForWinner()<\/code> function every time the user guesses a letter correctly.<\/strong> We&#8217;re checking if the user guessed correctly in <code>handleKeyboardClick()<\/code>. We can add an <code>else <\/code>clause to our conditional statement at the end of that function and call our <code>checkForWinner()<\/code> function in the body of the <code>else <\/code>clause. This guarantees that every time the user has a match, we check if they won.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function handleKeyboardClick(event) {\n    var clickedElement = event.target;\n\n    if (!clickedElement.classList.contains(\"letter\") || clickedElement.classList.contains(\"selected\")) return;\n\n    clickedElement.classList.add(\"selected\");\n\n    var clickedLetter = clickedElement.textContent;\n    var hasMatch = checkForMatch(clickedLetter);\n\n    if (!hasMatch) {\n        removeSnowmanPart();\n        checkForLoser();\n    } <mark>else {\n        checkForWinner();\n    }<\/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:\/\/lh4.googleusercontent.com\/7iiK8ttXPnpVj3DniV1MxHc4BEL45PUl3m_GYetigcP-lS6OXJnDEjr0qNarMwmmlyZuX5KgGFTcRLS962IC4V79scN59W9hRXuS6RpI6rio9tmHkeSPMlqKDMQsfRDo_wlkiKsZEJVAG6lFmOQhfV4ODtp7C1yTLyZPNv_W5ipW4XAkqOQhURUKRbdlpw\" alt=\"Javascript tutorial step 5\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"#complete\">Your program is complete!<\/h2>\n\n\n\n<p>Check out the finished <a href=\"https:\/\/projects.codewizardshq.com\/x_hour_of_code_2022\/javascript-projects\/disappearing-snowman\/index.html\">Disappearing Snowman Game<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/JVzwtYzgybCBDJko7DdH_GuSW2nvID6dw8PG5ANp8LUZCP-1MyDpYgnyMccDmLA-QkFs7IW6hhUiEP_NzdaMS3BGTl9OOd4jDsv_khnpDYRbv1wewmEYg27Of4UpOVd4K3W04FUgPtcT-hjDLWSYgh_mHcFw94E6LrdyI1ELbmFytNlk-MPi8N0zoWu45Q\" alt=\"Javascript tutorial completed game\"\/><\/figure>\n\n\n\n<p><strong>Download the <\/strong><a href=\"https:\/\/drive.google.com\/drive\/folders\/1pwLzaAt3xk3fHKvSt7t6lBsb4A2BY_2C?usp=share_link\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>project files<\/strong><\/a><strong> and open <\/strong>app.js<strong> to view the completed project.<\/strong><\/p>\n\n\n\n<p>This is just an example of what you can build when you learn JavaScript. There are plenty of exciting projects you can try and continue to build your skills.<\/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=\"https:\/\/www.codewizardshq.com\/\">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 core tracks 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.&nbsp;<\/p>\n\n\n\n<p>Have fun and happy holidays!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Guess the right word before your snowman melts!&nbsp; We\u2019ve created this tutorial just in time for the holidays. Code a fun word game that you can share with family and friends.&nbsp; This Christmas-themed guessing game uses simple JavaScript code to power the game functions. Try coding this game following the tutorial and then customize it [&hellip;]<\/p>\n","protected":false},"author":336,"featured_media":53340,"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":[10741,10739,10814],"class_list":["post-53334","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-activities","category-learn-coding","tag-html-css","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: Disappearing Snowman | CodeWizardsHQ<\/title>\n<meta name=\"description\" content=\"Holiday JavaScript coding tutorial for kids. Code your own disappearing snowman game using JavaScript and play with friends and family!\" \/>\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-disappearing-snowman\/\" \/>\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: Disappearing Snowman\" \/>\n<meta property=\"og:description\" content=\"Holiday JavaScript coding tutorial for kids. Code your own disappearing snowman game using JavaScript and play with friends and family!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/\" \/>\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-12-05T14:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-29T09:34:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"395\" \/>\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-disappearing-snowman\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/\"\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: Disappearing Snowman\",\n\t            \"datePublished\": \"2022-12-05T14:00:00+00:00\",\n\t            \"dateModified\": \"2025-08-29T09:34:49+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/\"\n\t            },\n\t            \"wordCount\": 2327,\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-disappearing-snowman\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1.png\",\n\t            \"keywords\": [\n\t                \"HTML\/CSS\",\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-disappearing-snowman\/\",\n\t            \"url\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/\",\n\t            \"name\": \"JavaScript Tutorial for Kids: Disappearing Snowman | 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-disappearing-snowman\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1.png\",\n\t            \"datePublished\": \"2022-12-05T14:00:00+00:00\",\n\t            \"dateModified\": \"2025-08-29T09:34:49+00:00\",\n\t            \"description\": \"Holiday JavaScript coding tutorial for kids. Code your own disappearing snowman game using JavaScript and play with friends and family!\",\n\t            \"breadcrumb\": {\n\t                \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/#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-disappearing-snowman\/\"\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-disappearing-snowman\/#primaryimage\",\n\t            \"url\": \"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1.png\",\n\t            \"contentUrl\": \"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1.png\",\n\t            \"width\": 1600,\n\t            \"height\": 395,\n\t            \"caption\": \"Disappearing snowman banner\"\n\t        },\n\t        {\n\t            \"@type\": \"BreadcrumbList\",\n\t            \"@id\": \"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/#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: Disappearing Snowman\"\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: Disappearing Snowman | CodeWizardsHQ","description":"Holiday JavaScript coding tutorial for kids. Code your own disappearing snowman game using JavaScript and play with friends and family!","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-disappearing-snowman\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Tutorial for Kids: Disappearing Snowman","og_description":"Holiday JavaScript coding tutorial for kids. Code your own disappearing snowman game using JavaScript and play with friends and family!","og_url":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/","og_site_name":"CodeWizardsHQ","article_publisher":"https:\/\/www.facebook.com\/codewizardshq\/","article_published_time":"2022-12-05T14:00:00+00:00","article_modified_time":"2025-08-29T09:34:49+00:00","og_image":[{"width":1600,"height":395,"url":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1.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-disappearing-snowman\/#article","isPartOf":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/"},"author":{"name":"Daniel Schroeder","@id":"https:\/\/www.codewizardshq.com\/#\/schema\/person\/8f483c66dd46a2d608d50adde5c5c0f2"},"headline":"JavaScript Tutorial for Kids: Disappearing Snowman","datePublished":"2022-12-05T14:00:00+00:00","dateModified":"2025-08-29T09:34:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/"},"wordCount":2327,"publisher":{"@id":"https:\/\/www.codewizardshq.com\/#organization"},"image":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1.png","keywords":["HTML\/CSS","JavaScript","tutorials"],"articleSection":["Activities","Learn Coding"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/","url":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/","name":"JavaScript Tutorial for Kids: Disappearing Snowman | CodeWizardsHQ","isPartOf":{"@id":"https:\/\/www.codewizardshq.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/#primaryimage"},"image":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1.png","datePublished":"2022-12-05T14:00:00+00:00","dateModified":"2025-08-29T09:34:49+00:00","description":"Holiday JavaScript coding tutorial for kids. Code your own disappearing snowman game using JavaScript and play with friends and family!","breadcrumb":{"@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/#primaryimage","url":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1.png","contentUrl":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1.png","width":1600,"height":395,"caption":"Disappearing snowman banner"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codewizardshq.com\/javascript-tutorial-for-kids-disappearing-snowman\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codewizardshq.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript Tutorial for Kids: Disappearing Snowman"}]},{"@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\/Disappearing-snowman-banner-1-600x395.png","featured_image_src_square":"https:\/\/www.codewizardshq.com\/wp-content\/uploads\/2022\/11\/Disappearing-snowman-banner-1-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\/53334","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=53334"}],"version-history":[{"count":2,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/posts\/53334\/revisions"}],"predecessor-version":[{"id":71751,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/posts\/53334\/revisions\/71751"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/media\/53340"}],"wp:attachment":[{"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/media?parent=53334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/categories?post=53334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codewizardshq.com\/wp-json\/wp\/v2\/tags?post=53334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}