diff --git a/01/app.js b/01/app.js index e69de29..5fd3c93 100644 --- a/01/app.js +++ b/01/app.js @@ -0,0 +1,9 @@ +let users = [ + 'Jan Kowalski', + 'Grzegorz Małolepszy', + 'Adam Nieproszony', + 'Katarzyna Nowak', + 'Olga Zarzeczna', +]; + +console.log(users[0], users[2], users[4], users.length); diff --git a/02/app.js b/02/app.js index 9ad302b..960a8e5 100644 --- a/02/app.js +++ b/02/app.js @@ -1,7 +1,15 @@ const randomArray = createRandomArray(); console.log(randomArray); +for (let i = 0; i <= randomArray.length - 1; i++) { + console.log(randomArray[i]); +} + +randomArray.forEach((num) => { + console.log(num); +}); +console.log(randomArray[randomArray.length - 1]); // nie modyfikuj kodu poniżej! @@ -9,15 +17,15 @@ console.log(randomArray); // ponieważ w JS występuje mechanizm tzw. hoisting-u function createRandomArray() { - const arr = []; - const len = getRandomInteger(1, 10) - for(let i=0; i currentYear - year); diff --git a/05/app.js b/05/app.js index 1c6bb90..d5877bf 100644 --- a/05/app.js +++ b/05/app.js @@ -1 +1,7 @@ -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 sum = numbers + .filter((num) => num % 2 === 0) + .reduce((prev, curr) => curr + prev); + +console.log(sum);