From 58d1b54b0d8da198a7b4b55ccd3762a24d206139 Mon Sep 17 00:00:00 2001 From: Whfkqreodgh Date: Wed, 8 Apr 2026 16:55:48 +0800 Subject: [PATCH] Add: tips and sol for 03_number_guessing_game --- 01-html_css_basics/README.md | 43 +++++++++ 01-html_css_basics/images/youtube_head.png | Bin 0 -> 3181 bytes 03-number_guessing/README.md | 11 +++ 03-number_guessing/hint.md | 88 ++++++++++++++++++ .../index.html | 1 + 03-number_guessing/solution.js | 39 ++++++++ .../README.md | 0 .../img/avengers_3.jpg | Bin .../index.html | 0 .../script.js | 0 .../style.css | 0 .../LICENSE | 14 +-- .../README.md | 0 .../img/carin.jpg | Bin .../img/gmail.jpg | Bin .../img/lynn.jpg | Bin .../img/yui.jpg | Bin .../img/yuki.jpg | Bin .../img/yuno.jpg | Bin .../manifest.json | 16 ++-- .../newtab_modern.html | 0 .../script.js | 0 .../styles.css | 0 package-lock.json | 6 ++ 24 files changed, 203 insertions(+), 15 deletions(-) create mode 100644 01-html_css_basics/README.md create mode 100644 01-html_css_basics/images/youtube_head.png create mode 100644 03-number_guessing/README.md create mode 100644 03-number_guessing/hint.md rename {01-number_guessing => 03-number_guessing}/index.html (90%) create mode 100644 03-number_guessing/solution.js rename {03-movie_website => 04-movie_website}/README.md (100%) rename {03-movie_website => 04-movie_website}/img/avengers_3.jpg (100%) rename {03-movie_website => 04-movie_website}/index.html (100%) rename {03-movie_website => 04-movie_website}/script.js (100%) rename {03-movie_website => 04-movie_website}/style.css (100%) rename {04-quick-access-tab => 06-quick-access-tab}/LICENSE (99%) rename {04-quick-access-tab => 06-quick-access-tab}/README.md (100%) rename {04-quick-access-tab => 06-quick-access-tab}/img/carin.jpg (100%) rename {04-quick-access-tab => 06-quick-access-tab}/img/gmail.jpg (100%) rename {04-quick-access-tab => 06-quick-access-tab}/img/lynn.jpg (100%) rename {04-quick-access-tab => 06-quick-access-tab}/img/yui.jpg (100%) rename {04-quick-access-tab => 06-quick-access-tab}/img/yuki.jpg (100%) rename {04-quick-access-tab => 06-quick-access-tab}/img/yuno.jpg (100%) rename {04-quick-access-tab => 06-quick-access-tab}/manifest.json (96%) rename {04-quick-access-tab => 06-quick-access-tab}/newtab_modern.html (100%) rename {04-quick-access-tab => 06-quick-access-tab}/script.js (100%) rename {04-quick-access-tab => 06-quick-access-tab}/styles.css (100%) create mode 100644 package-lock.json diff --git a/01-html_css_basics/README.md b/01-html_css_basics/README.md new file mode 100644 index 0000000..df9341c --- /dev/null +++ b/01-html_css_basics/README.md @@ -0,0 +1,43 @@ +# 03: Basics of HTML and CSS +This tutorial introduces the building blocks of the web: HTML for structure and CSS for presentation. + +## đź§± HTML (HyperText Markup Language) +HTML is the standard markup language used to create the structure of web pages. + +### Example of an HTML File +``` + + + + Page Title + + + +

My First Heading

+

My first paragraph.

+
+        Then leaf subsides to leaf.
+        So Eden sank to grief,
+        So dawn goes down to day.
+        Nothing gold can stay.
+    
+ + +``` + +### Essential Tags +``````: The tag that indicates an html file. + +``````: The root element that wraps all content on the entire page. + +``````: Contains meta-information about the HTML page, such as the title. As the following: +
+ + +``````: Defines the document's body and contains all the visible content (headings, paragraphs, images). + +```

``` to ```

```: Defines HTML headings, with ```

``` being the most important. + +```

```: Defines a paragraph. + +``````: Defines a hyperlink, using the href attribute to indicate the destination. \ No newline at end of file diff --git a/01-html_css_basics/images/youtube_head.png b/01-html_css_basics/images/youtube_head.png new file mode 100644 index 0000000000000000000000000000000000000000..e9c0e2d2dcb286e3f706df893469d873b4e970e2 GIT binary patch literal 3181 zcmV-z43hJSP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D3<60+K~#8N?cH5$ zTh##v@c*%$uQqWSCndNA*L;tOE_8u*8IsupuuWQ_6{}EGHz=v5sj4h^L6NqMX{ehN z^(lB$G-+)_8Xh``D9Sb=jfcq+idyhW)@ck_w_vEU!s3vmElHgC?BRaoe%Oh>?WF&o zbes5|>vOOBaQ->x+Vu#k|rz6e}fkXT7tk1PiPNU3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HbawGJ-%LV4LXQyLT@D;KGFq zru{^;N}I!&ot;HvVEz$YZ9utnv?yhAqm^RH2~_PdS~+vLZkI4ebW zt9gHx+S}XV^Z5Y4HkUCuIjNUfX~)H4F>6uT`2BwCE%wr%IGyYypPcld1O zcip!eP0g*Qx~%dKjpjzRkyjt+Gm=nx5)&T*d%J*Ng@LR816)mNdAh(*>uTO+F3Uk@ zXD0w)-@bj;qD?Cp44R$`F>a}PRzx>D?KzBiJdWn(W(*At;lT$VG)<1r%*^26!GmQ8 zjvTrgMU;PN_`S-lv)WLUDFY;cD&V7k0~ap=q5%-qO0NTQjld8}opDi0Zr%$7;ZFSu{EjTpBXF5uv zv@4CQEC0~g^EKr|xzr^@gkc#Gq5Z5b>{g0{|R6cn~lQSEXuoeb znCb8y14CmhJ9X-mwYa!)7@jJo{6pjL_mss27n8~|=t;veB0~Ls4W|Qe zxmLF-m-+iMq`HhqQYv*UCY3rnziT~P!R+6^AAvvsp-{*a9MNbLp->3HV9+%2oa!la z?M|g^X>%V+K*F-E zD9`sHDV4jV8tQmmbdcFE2zwy|Cfq|TQMMO7? zOjfVWcLLxYHj zHZ@adxHuw2L{u`lwz=gTk1>Ttp6de=5m6RgIga(nG7jTgdK%@s5F(&EQi5Max%8Jtg-0s;JsUf7)J1Rs( zR7Nw`C9cd=c9YCL1`$z(Xxb{^-B#H>4)!#Nh$_srMTyw7L^6x-Xet$k1`$yON~{1= zUrNk$k(0KU8-F~0!JFO+xKilIS7L>c=(Gvl@T T>Ci&W00000NkvXXu0mjfruq75 literal 0 HcmV?d00001 diff --git a/03-number_guessing/README.md b/03-number_guessing/README.md new file mode 100644 index 0000000..d670469 --- /dev/null +++ b/03-number_guessing/README.md @@ -0,0 +1,11 @@ +# Demo Mini-Project + +## Number Guessing Game + +You are required to build a game that generates **a random integer from a random range**. + +The user will guess the number. You need to indicate whether the guess is **too small**, **too big**, or **correct**. + +Complete the JavaScript part of the ```index.html``` file. + +If you ever get stuck, feel free to check the ```hint.md``` for hints and the ```solution.js``` for the solution. \ No newline at end of file diff --git a/03-number_guessing/hint.md b/03-number_guessing/hint.md new file mode 100644 index 0000000..902fa58 --- /dev/null +++ b/03-number_guessing/hint.md @@ -0,0 +1,88 @@ +# Hints + +## Step 1: Create a Random Number + +Use JavaScript to generate random numbers: + +``` +Math.random() // random number between 0 and 1 +``` + +To create an interger in the range (min, min + range): + +``` +Math.floor(Math.random() * range) + min +``` + +## Step 2 (optional): Create a Random Range + +Instead of always generating a number from 1 to 100, try: + +* Generate a **random minimum** +* Generate a **random maximum** + +Make sure that: + +```max > min``` and ```max - min >= range``` + +# Get User Input + +Notice that there's already an `````` box in HTML + +Useful syntax: + +``` +document.getElementById("html_id"); +``` + +To get the value of HTML input: + +```variableName.value``` + +**Tip:** The input from HTML returns a **string**, but you want a **number** + +## Step 4: Compare the Guess + +Use conditional statements: + +``` +if (condition 1) +{ + // too small +} +else if(condition 2) +{ + // too big +} +else +{ + // correct +} +``` + +## Step 5: Display Messages + +The ```

+ \ No newline at end of file diff --git a/03-number_guessing/solution.js b/03-number_guessing/solution.js new file mode 100644 index 0000000..d2400ad --- /dev/null +++ b/03-number_guessing/solution.js @@ -0,0 +1,39 @@ +// Generate a random range +const min = Math.floor(Math.random() * 50) + 1; // 1–50 +const max = min + Math.floor(Math.random() * 50) + 25; // ensure range width + +// Generate the target number within the range +const target = Math.floor(Math.random() * (max - min + 1)) + min; + +// console.log(`Debug: number is ${target} (range ${min}-${max})`); + +const form = document.querySelector("form"); +const input = document.getElementById("userinput"); +const answerDiv = document.getElementById("answer"); + +// Show initial instruction +answerDiv.textContent = `Guess a number between ${min} and ${max}`; + +form.addEventListener("submit", function(event) { + event.preventDefault(); // stop page reload + + const guess = Number(input.value); + + // Validate input + if (isNaN(guess)) { + answerDiv.textContent = "Please enter a valid number."; + return; + } + + // Compare guess + if (guess < target) { + answerDiv.textContent = "Too small! Try again."; + } else if (guess > target) { + answerDiv.textContent = "Too big! Try again."; + } else { + answerDiv.textContent = `🎉 Correct! The number was ${target}.`; + } + + // Clear input + input.value = ""; +}); \ No newline at end of file diff --git a/03-movie_website/README.md b/04-movie_website/README.md similarity index 100% rename from 03-movie_website/README.md rename to 04-movie_website/README.md diff --git a/03-movie_website/img/avengers_3.jpg b/04-movie_website/img/avengers_3.jpg similarity index 100% rename from 03-movie_website/img/avengers_3.jpg rename to 04-movie_website/img/avengers_3.jpg diff --git a/03-movie_website/index.html b/04-movie_website/index.html similarity index 100% rename from 03-movie_website/index.html rename to 04-movie_website/index.html diff --git a/03-movie_website/script.js b/04-movie_website/script.js similarity index 100% rename from 03-movie_website/script.js rename to 04-movie_website/script.js diff --git a/03-movie_website/style.css b/04-movie_website/style.css similarity index 100% rename from 03-movie_website/style.css rename to 04-movie_website/style.css diff --git a/04-quick-access-tab/LICENSE b/06-quick-access-tab/LICENSE similarity index 99% rename from 04-quick-access-tab/LICENSE rename to 06-quick-access-tab/LICENSE index 70342c9..e2186a5 100644 --- a/04-quick-access-tab/LICENSE +++ b/06-quick-access-tab/LICENSE @@ -1,7 +1,7 @@ -Copyright 2025 yszdlzn3195918 - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Copyright 2025 yszdlzn3195918 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/04-quick-access-tab/README.md b/06-quick-access-tab/README.md similarity index 100% rename from 04-quick-access-tab/README.md rename to 06-quick-access-tab/README.md diff --git a/04-quick-access-tab/img/carin.jpg b/06-quick-access-tab/img/carin.jpg similarity index 100% rename from 04-quick-access-tab/img/carin.jpg rename to 06-quick-access-tab/img/carin.jpg diff --git a/04-quick-access-tab/img/gmail.jpg b/06-quick-access-tab/img/gmail.jpg similarity index 100% rename from 04-quick-access-tab/img/gmail.jpg rename to 06-quick-access-tab/img/gmail.jpg diff --git a/04-quick-access-tab/img/lynn.jpg b/06-quick-access-tab/img/lynn.jpg similarity index 100% rename from 04-quick-access-tab/img/lynn.jpg rename to 06-quick-access-tab/img/lynn.jpg diff --git a/04-quick-access-tab/img/yui.jpg b/06-quick-access-tab/img/yui.jpg similarity index 100% rename from 04-quick-access-tab/img/yui.jpg rename to 06-quick-access-tab/img/yui.jpg diff --git a/04-quick-access-tab/img/yuki.jpg b/06-quick-access-tab/img/yuki.jpg similarity index 100% rename from 04-quick-access-tab/img/yuki.jpg rename to 06-quick-access-tab/img/yuki.jpg diff --git a/04-quick-access-tab/img/yuno.jpg b/06-quick-access-tab/img/yuno.jpg similarity index 100% rename from 04-quick-access-tab/img/yuno.jpg rename to 06-quick-access-tab/img/yuno.jpg diff --git a/04-quick-access-tab/manifest.json b/06-quick-access-tab/manifest.json similarity index 96% rename from 04-quick-access-tab/manifest.json rename to 06-quick-access-tab/manifest.json index 5ce0ec9..2f51350 100644 --- a/04-quick-access-tab/manifest.json +++ b/06-quick-access-tab/manifest.json @@ -1,9 +1,9 @@ -{ - "manifest_version": 3, - "name": "Quick Access Tab", - "version": "1.2.5", - "description": "Custom new tab with Google search + quick links", - "chrome_url_overrides": { - "newtab": "newtab_modern.html" - } +{ + "manifest_version": 3, + "name": "Quick Access Tab", + "version": "1.2.5", + "description": "Custom new tab with Google search + quick links", + "chrome_url_overrides": { + "newtab": "newtab_modern.html" + } } \ No newline at end of file diff --git a/04-quick-access-tab/newtab_modern.html b/06-quick-access-tab/newtab_modern.html similarity index 100% rename from 04-quick-access-tab/newtab_modern.html rename to 06-quick-access-tab/newtab_modern.html diff --git a/04-quick-access-tab/script.js b/06-quick-access-tab/script.js similarity index 100% rename from 04-quick-access-tab/script.js rename to 06-quick-access-tab/script.js diff --git a/04-quick-access-tab/styles.css b/06-quick-access-tab/styles.css similarity index 100% rename from 04-quick-access-tab/styles.css rename to 06-quick-access-tab/styles.css diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e878890 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "web-tutorial", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}