From ee7c3ba7d63d46247cb38220dfb0ac38b9694f88 Mon Sep 17 00:00:00 2001 From: Harald Fernengel <547273+haraldF@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:03:36 +0200 Subject: [PATCH] Add lesson10 (#10) --- index.html | 1 + lesson10.md | 73 ++++++++++++++++++++++++++++++++++++++++ preject/numberguess.html | 52 ++++++++++++++++++++++++++++ preject/webstore.html | 62 ++++++++++++++++++++++++++++++++++ toc.md | 2 +- 5 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 lesson10.md create mode 100644 preject/numberguess.html create mode 100644 preject/webstore.html diff --git a/index.html b/index.html index 1fd1b7f..bc45042 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,7 @@
+
diff --git a/lesson10.md b/lesson10.md new file mode 100644 index 0000000..2c39db6 --- /dev/null +++ b/lesson10.md @@ -0,0 +1,73 @@ + + +# Basic Frontend - Spring 2024 + +Lesson 10, Thursday, 2024-04-18 + +--- + +### Recap: getElementById + +* What is `getElementById`? +* When do we use it? +* What does it return? +* How do we find out which properties we can set/get? + +--- + +### MAJOR TWIST + +`string`, `boolean`, `number`, `undefined` and `null` are primitive data types + +`object` is a non-primitive data type + + +However - even primitive data types can have properties in JavaScript. + +--- + +### Example + +```js +let greeting = "Hello"; +let price = 1/3; + +greeting.replace('e', 'a'); // returns "Hallo" +price.toFixed(2) // returns "0.33" +``` + +We can use the `toFixed()` method on numbers to round to get a string with fewer digits after the decimal point. + +--- + +# Project + +--- + +### Option 1 + +Let's write a number guessing game! Let the computer guess a secret number between 1 and 100: + +```js +let secretNumber = Math.floor(Math.random() * 100) + 1; +``` + +Create a game web page where your user can guess any number between 1 and 100. The game must tell the user whether they guessed too high or too low. Once the user guesses the secret number, the game is over. + +BONUS: Also print the user's previous guesses + +--- + +### Option 2 + +Let's write a web shop! Choose **two** products of your liking and let the user select the amount they want to buy. Compute the total cost. + +BONUS: Also offer express shipping for a small extra fee. + +--- + +### Sample solutions + +[guessing game](preject/numberguess.html) + +[web store](preject/webstore.html) diff --git a/preject/numberguess.html b/preject/numberguess.html new file mode 100644 index 0000000..1c594ca --- /dev/null +++ b/preject/numberguess.html @@ -0,0 +1,52 @@ + + + + + + Number Guessing + + +

Guess the magic number!

+ + + +
Guess the magic number!
+
Previous guesses:
+ + + + + \ No newline at end of file diff --git a/preject/webstore.html b/preject/webstore.html new file mode 100644 index 0000000..a34eac0 --- /dev/null +++ b/preject/webstore.html @@ -0,0 +1,62 @@ + + + + + + + Webstore + + + +
+ + +
+
+ + +
+
+ + +
+
Total price: 0 EUR
+ + + + + \ No newline at end of file diff --git a/toc.md b/toc.md index 3667a7e..83321b9 100644 --- a/toc.md +++ b/toc.md @@ -8,6 +8,6 @@ 5. [DOM](#dom) -Direct link to lessons: [1](#lesson1) [2](#lesson2) [3](#lesson3) [4](#lesson4) [5](#lesson5) [6](#lesson6) [7](#lesson7) [8](#lesson8) [9](#lesson9) +Direct link to lessons: [1](#lesson1) [2](#lesson2) [3](#lesson3) [4](#lesson4) [5](#lesson5) [6](#lesson6) [7](#lesson7) [8](#lesson8) [9](#lesson9) [10](#lesson10) NOTE: when we have too many entries that don't fit on one screen we can use this