From 50c1e85931b592df03386fd1b5e5778f82082cfd Mon Sep 17 00:00:00 2001 From: Philippe Torrel Date: Mon, 2 Nov 2026 12:10:09 +0100 Subject: [PATCH] --- 07_js-debug/faq/reference-error.ts | 6 + .../tag41/04_error-types/03_type-error.html | 44 ++ .../tag41/04_error-types/04_type-error.js | 12 + .../tag41/04_error-types/04_type-error.ts | 23 ++ .../tag41/04_error-types/package-lock.json | 390 ++++++++++++++++++ .../tag41/04_error-types/package.json | 14 + .../tag41/05_logical-error/logical-error.html | 139 +++++++ .../unterricht/tag41/06_demo-form-bug.zip | Bin 0 -> 3901 bytes .../tag41/06_demo-form-bug/assets/js/main.js | 59 +++ .../tag41/06_demo-form-bug/index.html | 41 ++ 10 files changed, 728 insertions(+) create mode 100644 07_js-debug/unterricht/tag41/04_error-types/03_type-error.html create mode 100644 07_js-debug/unterricht/tag41/04_error-types/04_type-error.js create mode 100644 07_js-debug/unterricht/tag41/04_error-types/04_type-error.ts create mode 100644 07_js-debug/unterricht/tag41/04_error-types/package-lock.json create mode 100644 07_js-debug/unterricht/tag41/04_error-types/package.json create mode 100644 07_js-debug/unterricht/tag41/05_logical-error/logical-error.html create mode 100644 07_js-debug/unterricht/tag41/06_demo-form-bug.zip create mode 100644 07_js-debug/unterricht/tag41/06_demo-form-bug/assets/js/main.js create mode 100644 07_js-debug/unterricht/tag41/06_demo-form-bug/index.html diff --git a/07_js-debug/faq/reference-error.ts b/07_js-debug/faq/reference-error.ts index 5a24250..a6029df 100644 --- a/07_js-debug/faq/reference-error.ts +++ b/07_js-debug/faq/reference-error.ts @@ -27,4 +27,10 @@ // } greet('John Wick'); + + // function divide(a, b) { + // return a / b; + // } + + // console.log(divide(10)); // Expected 2 arguments, but got 1. } diff --git a/07_js-debug/unterricht/tag41/04_error-types/03_type-error.html b/07_js-debug/unterricht/tag41/04_error-types/03_type-error.html new file mode 100644 index 0000000..ccd9d2f --- /dev/null +++ b/07_js-debug/unterricht/tag41/04_error-types/03_type-error.html @@ -0,0 +1,44 @@ + + + + + + Type Error + + + + +
+
+

Type Error

+
+
+ + + diff --git a/07_js-debug/unterricht/tag41/04_error-types/04_type-error.js b/07_js-debug/unterricht/tag41/04_error-types/04_type-error.js new file mode 100644 index 0000000..73da071 --- /dev/null +++ b/07_js-debug/unterricht/tag41/04_error-types/04_type-error.js @@ -0,0 +1,12 @@ +"use strict"; +{ + function greet(name) { + console.log('Hello, ' + name); + } + function displayCar(car) { + console.log('Brand: ' + car.brand + ', Model: ' + car.model); + } + const myCar = { name: 'Toyota', model: 'Camry' }; + greet('11'); + displayCar({ brand: 'Honda', model: 'E' }); +} diff --git a/07_js-debug/unterricht/tag41/04_error-types/04_type-error.ts b/07_js-debug/unterricht/tag41/04_error-types/04_type-error.ts new file mode 100644 index 0000000..1eec014 --- /dev/null +++ b/07_js-debug/unterricht/tag41/04_error-types/04_type-error.ts @@ -0,0 +1,23 @@ +{ + interface Car { + brand: string; + model: string; + } + + function greet(name: string) { + console.log('Hello, ' + name); + } + + function displayCar(car: Car) { + console.log('Brand: ' + car.brand + ', Model: ' + car.model); + } + + const myCar = { name: 'Toyota', model: 'Camry' }; + + /* greet(42); // => TypeError: Argument of type 'number' is not assignable to parameter of type 'string' */ + + greet('11'); + + /* displayCar(myCar); // => TypeError: Argument of type '{ name: string; model: string; }' is not assignable to parameter of type 'Car'. Property 'brand' is missing in type '{ name: string; model: string; }' but required in type 'Car' */ + displayCar({ brand: 'Honda', model: 'E' }); +} diff --git a/07_js-debug/unterricht/tag41/04_error-types/package-lock.json b/07_js-debug/unterricht/tag41/04_error-types/package-lock.json new file mode 100644 index 0000000..ff8c471 --- /dev/null +++ b/07_js-debug/unterricht/tag41/04_error-types/package-lock.json @@ -0,0 +1,390 @@ +{ + "name": "04_error-types", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "04_error-types", + "version": "1.0.0", + "devDependencies": { + "typescript": "^7.0.2" + } + }, + "node_modules/@typescript/typescript-aix-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", + "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", + "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", + "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", + "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", + "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", + "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", + "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-loong64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", + "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-mips64el": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", + "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", + "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-riscv64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", + "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-s390x": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", + "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", + "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", + "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", + "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", + "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", + "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-sunos-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", + "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", + "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", + "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/typescript": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", + "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc" + }, + "engines": { + "node": ">=16.20.0" + }, + "optionalDependencies": { + "@typescript/typescript-aix-ppc64": "7.0.2", + "@typescript/typescript-darwin-arm64": "7.0.2", + "@typescript/typescript-darwin-x64": "7.0.2", + "@typescript/typescript-freebsd-arm64": "7.0.2", + "@typescript/typescript-freebsd-x64": "7.0.2", + "@typescript/typescript-linux-arm": "7.0.2", + "@typescript/typescript-linux-arm64": "7.0.2", + "@typescript/typescript-linux-loong64": "7.0.2", + "@typescript/typescript-linux-mips64el": "7.0.2", + "@typescript/typescript-linux-ppc64": "7.0.2", + "@typescript/typescript-linux-riscv64": "7.0.2", + "@typescript/typescript-linux-s390x": "7.0.2", + "@typescript/typescript-linux-x64": "7.0.2", + "@typescript/typescript-netbsd-arm64": "7.0.2", + "@typescript/typescript-netbsd-x64": "7.0.2", + "@typescript/typescript-openbsd-arm64": "7.0.2", + "@typescript/typescript-openbsd-x64": "7.0.2", + "@typescript/typescript-sunos-x64": "7.0.2", + "@typescript/typescript-win32-arm64": "7.0.2", + "@typescript/typescript-win32-x64": "7.0.2" + } + } + } +} diff --git a/07_js-debug/unterricht/tag41/04_error-types/package.json b/07_js-debug/unterricht/tag41/04_error-types/package.json new file mode 100644 index 0000000..0673e45 --- /dev/null +++ b/07_js-debug/unterricht/tag41/04_error-types/package.json @@ -0,0 +1,14 @@ +{ + "name": "04_error-types", + "version": "1.0.0", + "description": "", + "main": "04_type-error.js", + "scripts": { + "start": "npx tsc 04_type-error.ts --removeComments" + }, + "keywords": [], + "type": "commonjs", + "devDependencies": { + "typescript": "^7.0.2" + } +} diff --git a/07_js-debug/unterricht/tag41/05_logical-error/logical-error.html b/07_js-debug/unterricht/tag41/05_logical-error/logical-error.html new file mode 100644 index 0000000..781f934 --- /dev/null +++ b/07_js-debug/unterricht/tag41/05_logical-error/logical-error.html @@ -0,0 +1,139 @@ + + + + + + Logical Error + + + + +
+
+

Logical Error

+
+
+ + + diff --git a/07_js-debug/unterricht/tag41/06_demo-form-bug.zip b/07_js-debug/unterricht/tag41/06_demo-form-bug.zip new file mode 100644 index 0000000000000000000000000000000000000000..842c64ba062ab4928db44b79b407af83efe621e5 GIT binary patch literal 3901 zcmd5qp-j9%EWG{sGoR+Ui!`tus>pSy%<~j4nxvq0x&wbz5J;wUXEZhKeNm-MuzTABK z+6;&Sin|E5cCPO7_U@-$*3;@17WqOPQV6$)^cKW`IzrY~?1fZ}2 zPLL5C+0E9@8|~=n>cR-v83aBBE@*E!_Vje8B74n8nc(t%uQJx`=eo+Zp1uRMwajWo zyG|9Q6J;xl-DA>52`^8md8$by*e&|c+urham=B$0#vbf7HP=2-`>s8KiIP(QL~gv> z%oMdnSL^w^q*%R)_iwYRxH8b2D6_c8{D#-<2RYlPgA@xVS_MY*D3(1LX}d&f;reEK zk_Bjm_&Wt{bxoJ+M_})ZTwNXeU;%_2i#?WVg6FjOPMJhf9S?ofQ<1uT^)kkx>=aMz zF;rFF!c|Uf4ga~43ai&LHe9(c_z_Y{(%1H%irBW5?6gdK8F%Z)fAdZB(?LAY*FRApSUc`O&j-1(>`NmDHye2teU~t~|GG2B+;gei7={_@|#j?G% z6muMV&9+{+;of*N$1@dmV&Kj0?xf*`Vdv6{CWY$0Ll#YTP0g5N#llsDzxbSvYD87u z7Gu8emyi0W5f=_4H8p>{v5A@x0OlEq6w7!S<#ME+J3vfmSQW#yT^n| zm(!Pm@sV@pOYXfFmL;#0!|purTi7^I2HTUp=&O5HgL9@YP$T+onMA_jQNa+d))c1k zZDEepRKFtuD)6D>M>B_T3gbem zuOqxdZboQF_(&%ER5nL9itDJ5KKJXPunpnW2l7pf(zPdNkvZeipbCpcpi4Eo%WsGD()F@hmj;c1UW-Y zLJe8r_ntDnZjv*-av*>-cTOO#JJvwv-Ez<;&5raz?GD`op3_Pqk=~n|8|1Ea=u*$< zz$+`rk0;CuRJ&%n`P+k>C*|xaeMO9n`cs#@EVzqJck4%WFIJ7+zj~iQwVCQIdU`#* zjc`v0ix3+aJ7Tir*<**qE{T%QBTfd(7L)c;tYjPOVbqg$W=~p(Y;Oz0n1%WtUo_M| z;xAouTUw1U;4dJzFD&Tv1gX?Q5fH%K51d35ASbKQbd3yY&Q9!6~D4%f9 z{{3QT6yH#t7z1xdX4>xrV}@MlN9L{sUR&003}}Lr2csnZPO-ME6XK%qi93o&Rv|6y zg$#pOD!--+B|CVt7&;~G+O0&Kaco?kIW7fvCCU79a^hp-9Csqo+R-&3$%#ZJU$UpA z9l3HX)rm&x?jc-2$SI*77T@KBcJVb13Y65lPDT9C@5-FWzTb)5*tuk^rkqnY#5N~Lc%TuG_co&+}CN1fHlw)HuabPv1R zv@yY)txg~w&v7+2Pmgf1D?u+rC_1uJTgwz#e`!2&cV}<>^+Eiu0HY~pe~ZCX*ZC3= zfgBYD9@n|ii^!}39s?t${7JYoDSQ3av&ulem|P5Q>4}rWb^JPm)HwC9(giZMD3v_q z-`N5nL$M)ss-X|@@>|215GTV_wqTy+Wv$y{A<3+IJqAmzTl}-(vl9)2`R9B*nMy_D}4w(?M-DlWl!XqDZZGF4#tSpu?syd{Uno4QycS{qi zee_{&K9)8q`0v*ngI=}?KSI448Ly<}m)6ZxHb)5~$Hw4S?o>7Q3x}pCMx?g|+H0^% zXD%$(%w^U`q#Na#4-Xd%-A&w4b2t8>v4I*(ua?q5LJ#dP(oSDo&1LD&SzY<%_OEL8 z5z-cFPPmr+8Pm1TJhff&kLBer?V#ah^4Kg401!X9=gKUTU$brfs9-eVHxlmuy3Sxs z+{~*D&0uH$cF{1<%`aobFWrR|fPHOTUtzxw&-5dUAn*gWB1br+JKD}W{{)F!f=ImOr z{5BPIm@EGyq3Eb+7;!j*P*(H96{ilNuQV+BQ(we*uYu0U7eNBZwCI(B269u7YGGSlsWl7<MiNN Vl&qjS0I(kXOfv((jt$VSzX72wRQvz{ literal 0 HcmV?d00001 diff --git a/07_js-debug/unterricht/tag41/06_demo-form-bug/assets/js/main.js b/07_js-debug/unterricht/tag41/06_demo-form-bug/assets/js/main.js new file mode 100644 index 0000000..3de49ad --- /dev/null +++ b/07_js-debug/unterricht/tag41/06_demo-form-bug/assets/js/main.js @@ -0,0 +1,59 @@ +'use strict'; + +(() => { + // ===== DOM ===== + const DOM = { + calculateForm: document.querySelector('#calculateForm'), + firstNumberInput: document.querySelector('#firstNumber'), + secondNumberInput: document.querySelector('#secondNumber'), + result: document.querySelector('#result'), + }; + + // ===== INIT ===== + const init = () => { + DOM.calculateForm.addEventListener('submit', handleFormSubmit); + }; + + // ===== EVENT HANDLERS ===== + function handleFormSubmit(e) { + e.preventDefault(); + + if (checkIfInputsAreEmpty(DOM.firstNumberInput, DOM.secondNumberInput)) { + alert('Please enter a number in both fields'); + return; + } + + const num1 = getNumberValue(DOM.firstNumberInput); + const num2 = getNumberValue(DOM.secondNumberInput); + + const sum = add(num1, num2); + + displayResult(sum); + + DOM.calculateForm.reset(); + } + + // ===== FUNCTIONS ===== + function checkIfInputsAreEmpty(inputOne, inputTwo) { + if (inputOne.value && inputTwo.value) { + return false; + } else { + return true; + } + } + + function getNumberValue(input) { + return input.value; + } + + function add(a, b) { + return a + b; + } + + function displayResult(result) { + DOM.result.textContent = result; + } + + // ===== CALL INIT ===== + init(); +})(); diff --git a/07_js-debug/unterricht/tag41/06_demo-form-bug/index.html b/07_js-debug/unterricht/tag41/06_demo-form-bug/index.html new file mode 100644 index 0000000..1481789 --- /dev/null +++ b/07_js-debug/unterricht/tag41/06_demo-form-bug/index.html @@ -0,0 +1,41 @@ + + + + + + Debugging Demo + + + + +
+

Debugging Demo

+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+ +
Result:
+
+ +