-
Notifications
You must be signed in to change notification settings - Fork 205
all tasks finished #158
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?
all tasks finished #158
Changes from all commits
4ca7432
d4127e4
f53a421
88a1ef5
4e6f311
aa54821
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,3 @@ | ||
| { | ||
| "liveServer.settings.port": 5502 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,71 @@ | ||
| const a = '4.2'; | ||
| const b = 9; | ||
|
|
||
| console.log(a, b); | ||
| console.log(a, b); | ||
| console.log(typeof a); | ||
| console.log(typeof b); | ||
|
|
||
| const numA = parseFloat(a); | ||
|
|
||
| const res1 = numA + b; | ||
| const res2 = numA - b; | ||
| const res3 = numA * b; | ||
| const res4 = numA / b; | ||
| const res5 = numA % b; | ||
| let res6 = numA ; | ||
| res6++; | ||
| let res7 = b; | ||
| res7++; | ||
| let res8 = numA ; | ||
| res8--; | ||
| let res9 = b; | ||
| res9--; | ||
|
|
||
| // if(res1 > 20) { | ||
| // console.log('Wynik ' + res1 + ' jest wiekszy od 20!'); | ||
| // } else { | ||
| // console.log('Wynik ' + res1 + ' nie jest większy od 20!'); | ||
| // } | ||
|
|
||
| // if(res2 > 20) { | ||
| // console.log('Wynik ' + res2 + ' jest wiekszy od 20!'); | ||
| // } else { | ||
| // console.log('Wynik ' + res2 + ' nie jest większy od 20!'); | ||
| // } | ||
|
|
||
| // if(res3 > 20) { | ||
| // console.log('Wynik ' + res3 + ' jest wiekszy od 20!'); | ||
| // } else { | ||
| // console.log('Wynik ' + res3 + ' nie jest większy od 20!'); | ||
| // } | ||
|
|
||
| // if(res4 > 20) { | ||
| // console.log('Wynik ' + res4 + ' jest wiekszy od 20!'); | ||
| // } else { | ||
| // console.log('Wynik ' + res4 + ' nie jest większy od 20!'); | ||
| // } | ||
|
|
||
| // if(res5 > 20) { | ||
| // console.log('Wynik ' + res5 + ' jest wiekszy od 20!'); | ||
| // } else { | ||
| // console.log('Wynik ' + res5 + ' nie jest większy od 20!'); | ||
| // } | ||
|
|
||
|
|
||
| // console.log(res1, res2, res3, res4, res5, res6, res7, res8, res9); | ||
|
|
||
|
|
||
| function checkResult(resultNumber, result) { | ||
| if(result > 20) { | ||
| console.log(resultNumber + ' jest większy od 20!'); | ||
| } else { | ||
| console.log(resultNumber + ' nie jest większy od 20!'); | ||
| } | ||
| } | ||
|
|
||
| checkResult(`Wynik ${res1}`, res1); | ||
| checkResult(`Wynik ${res2}`, res2); | ||
| checkResult(`Wynik ${res3}`, res3); | ||
| checkResult(`Wynik ${res4}`, res4); | ||
| checkResult(`Wynik ${res5}`, res5); | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,23 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="pl"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <meta | ||
| name="viewport" | ||
| content="width=device-width, initial-scale=1.0" | ||
| > | ||
| <meta | ||
| http-equiv="X-UA-Compatible" | ||
| content="ie=edge" | ||
| > | ||
| <title>devmentor.pl - JS BASICS - #01</title> | ||
| </head> | ||
|
|
||
| <body> | ||
|
|
||
|
|
||
|
|
||
| <script src="./assets/js/app.js"></script> | ||
| </body> | ||
|
|
||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,41 @@ | ||
|
|
||
| /* rozwiązanie z pętlą for */ | ||
| const x = 4; | ||
| // const x = Number(prompt('Podaj liczbę od 1 do 9!')); | ||
|
|
||
| // if(x >= 1 && x <= 9) { | ||
| // for(let i=1; i<=9; i++) { | ||
| // const result = x * i; | ||
| // console.log(x + ' x ' + i + ' = ' + result); | ||
| // } | ||
| // } else { | ||
| // console.log(alert('Podałeś niepoprawną liczbę!')); | ||
| // } | ||
|
|
||
|
|
||
| /* rozwiązanie z pętlą while */ | ||
| /* rozwiązanie z pętlą while */ | ||
|
|
||
| const a = Number(prompt('Podaj podstawę!')) | ||
| const n = Number(prompt('Podaj wykładnik!')) | ||
|
|
||
|
|
||
| if(a > 0 && n > 0) { | ||
| let result = 1 | ||
| let counter = 1 | ||
| let showCalculation = '' | ||
|
|
||
| while(counter <= n) { | ||
| result = result * a | ||
|
|
||
| if(counter === 1) { | ||
| showCalculation = showCalculation + a | ||
| } else { | ||
| showCalculation = showCalculation + ' * ' + a | ||
| } | ||
|
|
||
| counter++ | ||
| } | ||
|
|
||
| console.log(showCalculation + ' = ' + result); | ||
| } else { | ||
| console.log(alert('Podaj liczbę większą od 0')); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,23 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="pl"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <meta | ||
| name="viewport" | ||
| content="width=device-width, initial-scale=1.0" | ||
| > | ||
| <meta | ||
| http-equiv="X-UA-Compatible" | ||
| content="ie=edge" | ||
| > | ||
| <title>devmentor.pl - JS BASICS - #02</title> | ||
| </head> | ||
|
|
||
| <body> | ||
|
|
||
|
|
||
|
|
||
| <script src="app.js"></script> | ||
| </body> | ||
|
|
||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,58 @@ console.log(a, b, c); | |
|
|
||
| function randomNumber(min, max) { | ||
| return Math.round((Math.random() * (max - min)) + min); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| function getSum(a, b, c) { | ||
| const num1 = Math.floor(a) | ||
| const num2 = Math.floor(b) | ||
| const num3 = Math.floor(c) | ||
|
|
||
| let largestNumber = Math.max(num1, num2, num3) | ||
| let middleNumber | ||
|
|
||
| if(largestNumber === num1) { | ||
| middleNumber = Math.max(num2, num3) | ||
| } else if (largestNumber === num2) { | ||
| middleNumber = Math.max(num1, num3) | ||
| } else { | ||
| middleNumber = Math.max(num1, num2) | ||
| } | ||
| return largestNumber + middleNumber | ||
|
Comment on lines
+26
to
+36
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. Lepiej by było wrzucić do tablicy, posortować i mamy dwie największe dużo prościej :) |
||
| } | ||
|
|
||
|
|
||
|
|
||
| const isEven = function(number) { | ||
| if(typeof number !== 'number') { | ||
| return null | ||
| } | ||
| return number % 2 === 0 | ||
| } | ||
|
|
||
|
|
||
|
|
||
| function showInfo(anyValue, specificValue) { | ||
| switch(specificValue) { | ||
| case null: | ||
| console.log('Podany argument ' + anyValue + ' nie jest liczbą!'); | ||
| break | ||
| case true: | ||
| console.log('Podany argument ' + anyValue + ' jest parzysty!'); | ||
| break | ||
| case false: | ||
| console.log('Podany argument ' + anyValue + ' jest nieparzysty!'); | ||
| break | ||
| default: | ||
| console.log('Nieprawidłowa wartość!'); | ||
| } | ||
| } | ||
|
|
||
| const sum = getSum(a, b, c) | ||
| console.log(sum); | ||
|
|
||
| const even = isEven(sum) | ||
| console.log(even); | ||
|
|
||
| showInfo(sum, even) | ||
|
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,12 +1,21 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="pl"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <meta | ||
| name="viewport" | ||
| content="width=device-width, initial-scale=1.0" | ||
| > | ||
| <meta | ||
| http-equiv="X-UA-Compatible" | ||
| content="ie=edge" | ||
| > | ||
| <title>devmentor.pl - JS BASICS - #04</title> | ||
| </head> | ||
|
|
||
| <body> | ||
|
|
||
| <script src="script.js"></script> | ||
| </body> | ||
|
|
||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| 'use strict' | ||
|
|
||
| function createArray(min, max) { | ||
| const newArray = [] | ||
|
|
||
| for(let i=0; i < 20; i++) { | ||
| const randomNumber = Math.round((Math.random() * (max - min)) + min); | ||
| newArray.push(randomNumber) | ||
| } | ||
|
|
||
| return newArray | ||
|
|
||
| } | ||
|
|
||
|
|
||
| function get10LargestNumbers(array) { | ||
| const sortedArray = array.sort(function(a, b) | ||
| { | ||
| return b - a | ||
| }); | ||
|
|
||
| return sortedArray.slice(0, 10) | ||
|
|
||
| } | ||
|
|
||
|
|
||
| function calculateAverage(array) { | ||
| if(array.length === 0) { | ||
| return 0 | ||
| } | ||
|
|
||
| const sumArrNumbers = array.reduce(function(acc, currentValue) { | ||
| return acc + currentValue | ||
| }, 0) | ||
|
|
||
| return sumArrNumbers / array.length | ||
| } | ||
|
|
||
|
|
||
|
|
||
| const min = 10 | ||
| const max = 200 | ||
|
|
||
| const array = createArray(min, max) | ||
| console.log('Wygenerowana tablica: ' + array); | ||
|
|
||
| const largestNumbers = get10LargestNumbers(array) | ||
| console.log('10 największych liczb z tablicy: ' + largestNumbers); | ||
|
|
||
| const average = calculateAverage(largestNumbers) | ||
| console.log('Średnia arytmetyczna 10-ciu największych liczb z tablicy: ' + average); | ||
|
|
||
|
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,12 +1,23 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="pl"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <meta | ||
| name="viewport" | ||
| content="width=device-width, initial-scale=1.0" | ||
| > | ||
| <meta | ||
| http-equiv="X-UA-Compatible" | ||
| content="ie=edge" | ||
| > | ||
| <title>devmentor.pl - JS BASICS - #05</title> | ||
| </head> | ||
|
|
||
| <body> | ||
|
|
||
|
|
||
|
|
||
| <script src="script.js"></script> | ||
| </body> | ||
|
|
||
| </html> |
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.
👍