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
10 changes: 10 additions & 0 deletions 01/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const users = new Array("John Doe", "John Smith", "Joe Bonamassa", "Mia Davis", "Ava Miller");


console.log(`Pierwsza pozycja w zmiennej 'users' to: ${users[0]}`);
console.log(`Trzecia pozycja w zmiennej 'users' to: ${users[2]}`);
console.log(`Piąta pozycja w zmiennej 'users' to: ${users[4]}`);


console.log(`Zmienna 'users' zawiera: ${users.length} pozycji`);

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: 12 additions & 3 deletions 02/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ const randomArray = createRandomArray();
console.log(randomArray);


for (let j = 0; j < randomArray.length; j++) {
console.log(`Pozycja nr ${j + 1}: ${randomArray[j]} === for(){} ===`);
};

randomArray.forEach((e, i) => {
console.log(`Pozycja nr ${i + 1}: ${e} === forEach() ===`);
});

console.log(`Ostatnia pozycja w 'randomArray to: '${randomArray[randomArray.length - 1]}`);
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.

👍


// nie modyfikuj kodu poniżej!

Expand All @@ -11,13 +20,13 @@ console.log(randomArray);
function createRandomArray() {
const arr = [];
const len = getRandomInteger(1, 10)
for(let i=0; i<len; i++) {
arr.push( getRandomInteger(1, 100) );
for (let i = 0; i < len; i++) {
arr.push(getRandomInteger(1, 100));
}

return arr;
}

function getRandomInteger(min, max) {
return Math.round(Math.random() * (max-min) + min);
return Math.round(Math.random() * (max - min) + min);
}
16 changes: 15 additions & 1 deletion 03/app.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
const n = 24;
const oddNumbers = [];
const oddNumbers = [];

if (n <= 0) {
console.log('Zmienna "n" jest mniejsza lub równa zeru!');
} else {
for (let i = 0; i <= n; i++) {
if (i % 2 !== 0) {
oddNumbers.push(i);
}
}
};

oddNumbers.forEach((e, i) => {
console.log(`Index: ${i}; Wartość: ${e}`);
});
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.

👍

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

const yearPoint = parseInt(prompt('Podaj rok, który będzie punktem odniesienia'));

if (!yearPoint | yearPoint < 0) {
alert('Wprowadzono niepoprawny format danych odśwież stronę i spróbuj jeszcze raz!');
} else {
const newYears = years.map((e) => e - yearPoint);
newYears.forEach((e, i) => {
console.log(`Między datą nr. ${i + 1} a punktem odniesienia jest ${e} lat różnicy`)
});
}
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 05/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
const numbers = [1, 2, 3, 4, 5, 6, 7];
const numbers = [1, 2, 3, 4, 5, 6, 7];

const evenNumbers = numbers.filter(e => e % 2 === 0);

const sum = evenNumbers.reduce((total, currentValue) => {
return total += currentValue
});

console.log(`The sum of the even numbers inside "numbers" array is: ${sum}`);