From b3bf61fb29e23f3db5b5b4c21ed0c1bded34a0ba Mon Sep 17 00:00:00 2001 From: Jarek Stelmach Date: Thu, 7 Mar 2024 18:00:39 +0100 Subject: [PATCH 1/5] Finished ex 1 in arrays --- 01/app.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/01/app.js b/01/app.js index e69de29..3a66e14 100644 --- a/01/app.js +++ b/01/app.js @@ -0,0 +1,7 @@ +const users = ["Jan Kowalski", "Marta Kieliszek", "Zenon Gminny", "Albert Sosna", "Michał Bułka"] + +console.log(users[0]); +console.log(users[2]); +console.log(users[4]); + +console.log("Tablica zwiera =", users.length); \ No newline at end of file From c4c4ad2d5c7f557448ce62f3d8db7ebee4efdd5f Mon Sep 17 00:00:00 2001 From: Jarek Stelmach Date: Thu, 7 Mar 2024 18:27:09 +0100 Subject: [PATCH 2/5] Finished ex 2 in arrays --- 02/app.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/02/app.js b/02/app.js index 9ad302b..c023a85 100644 --- a/02/app.js +++ b/02/app.js @@ -1,23 +1,33 @@ -const randomArray = createRandomArray(); -console.log(randomArray); +const randomArray = createRandomArray() +console.log(randomArray) +for (let i = 0; i < randomArray.length; i++) { + console.log(randomArray[i]) +} + +randomArray.forEach(function (el) { + console.log(el) +}) +console.log(randomArray[randomArray.length - 1]); + // nie modyfikuj kodu poniżej! // funkcję może deklarować poniżej wywołania // ponieważ w JS występuje mechanizm tzw. hoisting-u function createRandomArray() { - const arr = []; - const len = getRandomInteger(1, 10) - for(let i=0; i Date: Thu, 7 Mar 2024 19:10:44 +0100 Subject: [PATCH 3/5] Finished ex 3 in arrays --- 03/app.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/03/app.js b/03/app.js index cebcbc2..7a0666b 100644 --- a/03/app.js +++ b/03/app.js @@ -1,2 +1,21 @@ 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); + + + + + + + From 1c76c7a8c69d3b8f740252623cea78e98f0478c7 Mon Sep 17 00:00:00 2001 From: Jaro Date: Fri, 8 Mar 2024 09:59:43 +0100 Subject: [PATCH 4/5] Finished ex 4 for arrays --- 04/app.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/04/app.js b/04/app.js index 8285afd..7391243 100644 --- a/04/app.js +++ b/04/app.js @@ -1 +1,17 @@ -const years = [1980, 1934, 2002, 2019]; \ No newline at end of file +const years = [1980, 1934, 2002, 2019]; +const differenceYearsArr = []; + +const currentDate = new Date(); +const currentYear = currentDate.getFullYear(); + +// console.log(currentYear); + +years.forEach(function (el) { + // console.log(el); + const amountOfYears = currentYear - el; + // console.log(amountOfYears); + + differenceYearsArr.push(amountOfYears); +}); + +console.log(differenceYearsArr); From 78580ddf7c85743b1144c8f234c1b65f966f0622 Mon Sep 17 00:00:00 2001 From: Jaro Date: Fri, 8 Mar 2024 10:19:37 +0100 Subject: [PATCH 5/5] Finished ex 5 in arrays --- 05/app.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/05/app.js b/05/app.js index 1c6bb90..55be70b 100644 --- a/05/app.js +++ b/05/app.js @@ -1 +1,13 @@ -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(function(el) { + return el % 2 === 0 +}) + +console.log("Tablica z liczbami parzystymi", evenNumbers); + +const sumEvenNumbers = evenNumbers.reduce(function(a, b) { + return a + b; +}, 0); + +console.log("Suma liczb parzystych to", sumEvenNumbers); \ No newline at end of file