From 53a0723b0902c6f2ca53faf928a00924db1b5c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Wed, 15 Jan 2025 22:20:36 +0100 Subject: [PATCH 1/5] task 01 done --- .vscode/settings.json | 3 +++ 01/app.js | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/01/app.js b/01/app.js index e69de29..c6ddbaf 100644 --- a/01/app.js +++ b/01/app.js @@ -0,0 +1,3 @@ +const users = ['Jan Kowalski', 'Kasia Kowalska', 'Anna Janowska', 'Michał Janowski', 'Piotr Piotrowski']; + +console.log(users[0], users[2], users[4], users.length); \ No newline at end of file From c4efbdd10ac70d379c0aeb6d76d1c1ffae0fffc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Wed, 15 Jan 2025 22:41:46 +0100 Subject: [PATCH 2/5] task 02 done --- 02/app.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/02/app.js b/02/app.js index 9ad302b..3d23090 100644 --- a/02/app.js +++ b/02/app.js @@ -1,6 +1,20 @@ const randomArray = createRandomArray(); console.log(randomArray); +// wyswietlanie za pomoca pętli for +for(let i=0; i Date: Thu, 16 Jan 2025 22:01:05 +0100 Subject: [PATCH 3/5] task 03 done --- 03/app.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/03/app.js b/03/app.js index cebcbc2..e1481d5 100644 --- a/03/app.js +++ b/03/app.js @@ -1,2 +1,19 @@ const n = 24; -const oddNumbers = []; \ No newline at end of file +const oddNumbers = []; + +for(let i=1; i<=n; i++) { + if(i % 2 !== 0) { + oddNumbers.push(i); + } +} + +console.log(oddNumbers); + + +// nie do końca rozumiem o co chodzi z tym sprawdzaniem warunków brzegowych + +// przy 'n=0' miałem pustą tablicę [] +// prz 'n=1' miałem [1] +// przy 'n=100' miałem liczby nieparzyste o 1 do 99 + +//plus przy .push wstawiłem nawiasy kwadratowe za pierwszym razem i nie ukrywam, że było to dla mnie problemem bo nie wiedziałem gdzie jest bład, a vsc nic nie podświetlał \ No newline at end of file From eed49f0b1de843aca0ad75b2f166b12b7e41945a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Thu, 16 Jan 2025 22:19:50 +0100 Subject: [PATCH 4/5] task 04 done --- 04/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/04/app.js b/04/app.js index 8285afd..44a33e5 100644 --- a/04/app.js +++ b/04/app.js @@ -1 +1,10 @@ -const years = [1980, 1934, 2002, 2019]; \ No newline at end of file +const years = [1980, 1934, 2002, 2019]; + +const currentYear = new Date().getFullYear(); +console.log(currentYear); + +const yearsPassed = years.map(function(year) { + return currentYear - year; +}); + +console.log(yearsPassed); \ No newline at end of file From 3fedb4f686f306f5ae79328401c251cb4cdc3f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82?= Date: Thu, 16 Jan 2025 22:48:23 +0100 Subject: [PATCH 5/5] task 05 done --- 05/app.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/05/app.js b/05/app.js index 1c6bb90..a4e40c6 100644 --- a/05/app.js +++ b/05/app.js @@ -1 +1,16 @@ -const numbers = [1, 2, 3, 4, 5, 6, 7]; \ No newline at end of file +const numbers = [1, 2, 3, 4, 5, 6, 7]; + +const evenNumbersSum = numbers.filter(function(number) { + return number % 2 === 0; +}) + +.reduce(function(sum, number) { + return sum + number; +}); + +console.log(evenNumbersSum); + + +// jesli dobrze to rozumiem to .reduce() dodaje do siebie wszystkie elementy tablicy i zwraca je jako jedną wartość?? + +// czy raczej dodaje wszystkie elementy tablicy do pierwszego elementu (accumulator)?? \ No newline at end of file