Skip to content
Open

done #126

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
5 changes: 5 additions & 0 deletions 01/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const users = ['Jan Kowalski', 'Anna Polsza', 'Radek Kozak', 'Michał Radwan', "Katarzyna Jarek"];

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

console.log(users.length);
19 changes: 16 additions & 3 deletions 02/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
const randomArray = createRandomArray();
console.log(randomArray);

for (let i = 0; i < randomArray.length; i++) {
console.log(randomArray[i]);
}

randomArray.forEach(function (item) {
console.log(item);
});

const lastIndex = randomArray.length - 1;

console.log(randomArray[lastIndex])




// nie modyfikuj kodu poniżej!
Expand All @@ -11,13 +24,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);
}
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 === 1){
oddNumbers.push(i);
}
}

console.log(oddNumbers);
10 changes: 9 additions & 1 deletion 04/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
const years = [1980, 1934, 2002, 2019];
const years = [1980, 1934, 2002, 2019];

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

const ages = years.map(function(item){
return currYear - item;
});

console.log(ages);
17 changes: 16 additions & 1 deletion 05/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
const numbers = [1, 2, 3, 4, 5, 6, 7];
const numbers = [1, 2, 3, 4, 5, 6, 7];


const evenNumbers = numbers.filter(isEven);

console.log(evenNumbers);

function isEven(num){
return num % 2 === 0;
};

const sum = evenNumbers.reduce(function(acc, curr){
return acc + curr;
})

console.log(sum);