-
Notifications
You must be signed in to change notification settings - Fork 169
resolved tasks - arrays #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3808af5
6601cce
48c24b6
2651e27
64834fb
eb008e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| const users = ['Janusz Kowalski', 'Robert Lewandowski', 'Jan Pawel', 'Edzia Gorniak', 'Marcin Najman']; | ||
|
|
||
| console.log(users[0], users[2], users[4]); | ||
| console.log(users.length); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,4 +20,20 @@ function createRandomArray() { | |
|
|
||
| function getRandomInteger(min, max) { | ||
| return Math.round(Math.random() * (max-min) + min); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // function showArrayElement(arr){ | ||
| // for (let i=0; i < arr.length; i++){ | ||
| // console.log(arr[i]); | ||
| // } | ||
| // } | ||
|
|
||
| // showArrayElement(randomArray); | ||
|
|
||
| function showArrayElement(arr){ | ||
| arr.forEach((element) => console.log(element)); | ||
| console.log(` Ostatni element tablicy to: ${arr[arr.length - 1]}`); | ||
| } | ||
|
|
||
| showArrayElement(randomArray); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,22 @@ | ||
| const n = 24; | ||
| const oddNumbers = []; | ||
| const oddNumbers = []; | ||
|
|
||
| // for (let i = 0; i < n; i++){ | ||
| // if(i%2 !== 0) { | ||
| // oddNumbers.push(i); | ||
| // } | ||
| // } | ||
| // console.log(oddNumbers); | ||
|
|
||
| function showOddNumbers(maxValue){ | ||
| let arr = []; | ||
|
|
||
| for (let i = 0; i < maxValue; i++){ | ||
| if(i%2 !== 0) { | ||
| arr.push(i); | ||
| } | ||
| } | ||
| console.log(arr); | ||
| } | ||
|
|
||
| showOddNumbers(n); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| 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 currentDate = new Date(); | ||
| const currentYear = currentDate.getFullYear(); | ||
|
|
||
| const yearsToDate = years.map((element) => currentYear - element); | ||
| console.log(yearsToDate); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,17 @@ | ||
| const numbers = [1, 2, 3, 4, 5, 6, 7]; | ||
| const numbers = [1, 2, 3, 4, 5, 6, 7]; | ||
|
|
||
| // const sum = numbers.reduce((acc, el) => { | ||
| // if(el%2===0){ | ||
| // return acc+el; | ||
| // } | ||
| // return acc; | ||
| // }, 0); | ||
|
|
||
|
|
||
| // console.log(sum); | ||
|
|
||
|
|
||
| const evenNumbers = numbers.filter((element) => element%2===0); | ||
| const sum = evenNumbers.reduce((acc, el) => acc + el, 0); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| console.log(sum); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍