From a6e434266c2d409d130b4f09b45cb9e3801e88eb Mon Sep 17 00:00:00 2001 From: Grzegorz Stepien Date: Mon, 8 Apr 2024 18:03:14 +0200 Subject: [PATCH 1/5] finish 01 --- 01/app.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/01/app.js b/01/app.js index e69de29..5c339f9 100644 --- a/01/app.js +++ b/01/app.js @@ -0,0 +1,5 @@ +const users = ['Jan Kowalski', 'Anna Polsza', 'Radek Kozak', 'Michał Radwan', "Katarzyna Jarek"]; + +console.log(users[0], users[2], users[4]); + +console.log(users.length); \ No newline at end of file From b32dc8974df92cf71b2b2228f108c06a134ead6a Mon Sep 17 00:00:00 2001 From: Grzegorz Stepien Date: Mon, 8 Apr 2024 18:17:09 +0200 Subject: [PATCH 2/5] finish 02 --- 02/app.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/02/app.js b/02/app.js index 9ad302b..e183155 100644 --- a/02/app.js +++ b/02/app.js @@ -1,6 +1,19 @@ const randomArray = createRandomArray(); console.log(randomArray); +for (let i = 0; i < randomArray.length; i++) { + console.log(randomArray[i]); +} + +randomArray.forEach(function (item) { + console.log(item); +}); + +const lastIndex = randomArray.length - 1; + +console.log(randomArray[lastIndex]) + + // nie modyfikuj kodu poniżej! @@ -11,13 +24,13 @@ console.log(randomArray); function createRandomArray() { const arr = []; const len = getRandomInteger(1, 10) - for(let i=0; i Date: Mon, 8 Apr 2024 20:49:02 +0200 Subject: [PATCH 3/5] finish 03 --- 03/app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/03/app.js b/03/app.js index cebcbc2..d4ab2d8 100644 --- a/03/app.js +++ b/03/app.js @@ -1,2 +1,10 @@ const n = 24; -const oddNumbers = []; \ No newline at end of file +const oddNumbers = []; + +for( let i=1; i Date: Mon, 8 Apr 2024 20:55:40 +0200 Subject: [PATCH 4/5] finish 04 --- 04/app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/04/app.js b/04/app.js index 8285afd..ab8d92f 100644 --- a/04/app.js +++ b/04/app.js @@ -1 +1,9 @@ -const years = [1980, 1934, 2002, 2019]; \ No newline at end of file +const years = [1980, 1934, 2002, 2019]; + +const currYear = (new Date()).getFullYear(); + +const ages = years.map(function(item){ + return currYear - item; +}); + +console.log(ages); \ No newline at end of file From 6476644b07be156acb2fd10cd37fcefa9c9938d6 Mon Sep 17 00:00:00 2001 From: Grzegorz Stepien Date: Mon, 8 Apr 2024 21:09:16 +0200 Subject: [PATCH 5/5] finish 05 --- 05/app.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/05/app.js b/05/app.js index 1c6bb90..47462e1 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 evenNumbers = numbers.filter(isEven); + +console.log(evenNumbers); + +function isEven(num){ + return num % 2 === 0; +}; + +const sum = evenNumbers.reduce(function(acc, curr){ + return acc + curr; +}) + +console.log(sum); \ No newline at end of file