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 @@
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);
30 changes: 20 additions & 10 deletions 02/app.js
Original file line number Diff line number Diff line change
@@ -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<len; i++) {
arr.push( getRandomInteger(1, 100) );
}
const arr = []
const len = getRandomInteger(1, 10)
for (let i = 0; i < len; i++) {
arr.push(getRandomInteger(1, 100))
}

return arr;
console.log(arr)
return arr
}

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



for (let i=1; i<=n; i++) {

if (i % 2 !==0) {

oddNumbers.push(i)
}
}

console.log(oddNumbers);







18 changes: 17 additions & 1 deletion 04/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
const years = [1980, 1934, 2002, 2019];
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);
14 changes: 13 additions & 1 deletion 05/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
const numbers = [1, 2, 3, 4, 5, 6, 7];
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);