-
Notifications
You must be signed in to change notification settings - Fork 169
Tasks completed #148
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?
Tasks completed #148
Changes from all commits
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,9 @@ | ||
| let users = [ | ||
| 'Jan Kowalski', | ||
| 'Grzegorz Małolepszy', | ||
| 'Adam Nieproszony', | ||
| 'Katarzyna Nowak', | ||
| 'Olga Zarzeczna', | ||
| ]; | ||
|
|
||
| console.log(users[0], users[2], users[4], users.length); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,31 @@ | ||
| const randomArray = createRandomArray(); | ||
| console.log(randomArray); | ||
|
|
||
| for (let i = 0; i <= randomArray.length - 1; i++) { | ||
|
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. Chyba łatwiej jest też zapisać bez |
||
| console.log(randomArray[i]); | ||
| } | ||
|
|
||
| randomArray.forEach((num) => { | ||
| console.log(num); | ||
| }); | ||
|
|
||
| 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; | ||
| return arr; | ||
| } | ||
|
|
||
| function getRandomInteger(min, max) { | ||
| return Math.round(Math.random() * (max-min) + min); | ||
| } | ||
| return Math.round(Math.random() * (max - min) + min); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| const n = 24; | ||
| const oddNumbers = []; | ||
| const oddNumbers = []; | ||
|
|
||
| for (let i = 1; i <= n; i += 2) { | ||
| oddNumbers.push(i); | ||
| } | ||
|
|
||
| console.log(oddNumbers); | ||
|
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,3 @@ | ||
| const years = [1980, 1934, 2002, 2019]; | ||
| const years = [1980, 1934, 2002, 2019]; | ||
| const currentYear = new Date().getFullYear(); | ||
| const howLong = years.map((year) => currentYear - year); | ||
|
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 numbers = [1, 2, 3, 4, 5, 6, 7]; | ||
| const numbers = [1, 2, 3, 4, 5, 6, 7]; | ||
|
|
||
| const sum = numbers | ||
| .filter((num) => num % 2 === 0) | ||
| .reduce((prev, curr) => curr + prev); | ||
|
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. Warto na końcu dać 2 parametr tj. |
||
|
|
||
| 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.
👍