Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions 01/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
users = ['Jan Kowalski', 'Piotr Nowak', 'Zofia Kowalska', 'Anna Jankowska', 'Zygmunt Jakiś', 'Barbara Torba', 'Marianna Cymbał']

console.log(users[0])
console.log(users[2])
console.log(users[4])

console.log(users.length)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

15 changes: 14 additions & 1 deletion 02/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@ function createRandomArray() {

function getRandomInteger(min, max) {
return Math.round(Math.random() * (max-min) + min);
}
}

console.log("Wyświetlanie elementów tablicy za pomocą pętli `for`:");
for (let i = 0; i < randomArray.length; i++) {
console.log(randomArray[i]);
}

console.log("Wyświetlanie elementów tablicy za pomocą metody `.forEach()`:");
randomArray.forEach((element) => {
console.log(element);
});

const lastElement = randomArray[randomArray.length - 1];
console.log("Ostatni element tablicy:", lastElement);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

10 changes: 9 additions & 1 deletion 03/app.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
const n = 24;
const oddNumbers = [];
const oddNumbers = [];

for (let i = 1; i <= n; i++) {
if (i % 2 !== 0) {
oddNumbers.push(i);
}
}

console.log("Tablica liczb nieparzystych:", oddNumbers);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

8 changes: 7 additions & 1 deletion 04/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
const years = [1980, 1934, 2002, 2019];
const years = [1980, 1934, 2002, 2019];

const currentYear = new Date().getFullYear();

const yearsPassed = years.map(year => currentYear - year);

console.log(yearsPassed);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

9 changes: 8 additions & 1 deletion 05/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
const numbers = [1, 2, 3, 4, 5, 6, 7];
const numbers = [1, 2, 3, 4, 5, 6, 7];


const evenNumbersSum = numbers
.filter(number => number % 2 === 0)
.reduce((sum, number) => sum + number, 0);

console.log(evenNumbersSum);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍