diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..f673a71b
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "liveServer.settings.port": 5502
+}
\ No newline at end of file
diff --git a/01/assets/js/app.js b/01/assets/js/app.js
index 9323b98d..5751660b 100644
--- a/01/assets/js/app.js
+++ b/01/assets/js/app.js
@@ -1,4 +1,71 @@
const a = '4.2';
const b = 9;
-console.log(a, b);
\ No newline at end of file
+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);
+
diff --git a/01/index.html b/01/index.html
index 5c55d687..6e9c8216 100644
--- a/01/index.html
+++ b/01/index.html
@@ -1,12 +1,23 @@
+
-
-
+
+
devmentor.pl - JS BASICS - #01
+
-
+
+
+
+
\ No newline at end of file
diff --git a/02/app.js b/02/app.js
index b397190c..0c1f63b9 100644
--- a/02/app.js
+++ b/02/app.js
@@ -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 */
\ No newline at end of file
+/* 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'));
+}
diff --git a/02/index.html b/02/index.html
index 30150099..26aea3f7 100644
--- a/02/index.html
+++ b/02/index.html
@@ -1,12 +1,23 @@
+
-
-
+
+
devmentor.pl - JS BASICS - #02
+
-
+
+
+
+
\ No newline at end of file
diff --git a/03/app.js b/03/app.js
index 5b9361e4..7ec1169a 100644
--- a/03/app.js
+++ b/03/app.js
@@ -15,4 +15,58 @@ console.log(a, b, c);
function randomNumber(min, max) {
return Math.round((Math.random() * (max - min)) + min);
-}
\ No newline at end of file
+}
+
+
+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
+}
+
+
+
+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)
\ No newline at end of file
diff --git a/04/index.html b/04/index.html
index 06aebbb8..ba2bc690 100644
--- a/04/index.html
+++ b/04/index.html
@@ -1,12 +1,21 @@
+
-
-
+
+
devmentor.pl - JS BASICS - #04
+
-
+
+
\ No newline at end of file
diff --git a/04/script.js b/04/script.js
new file mode 100644
index 00000000..3fc17222
--- /dev/null
+++ b/04/script.js
@@ -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);
+
diff --git a/05/index.html b/05/index.html
index 52a42709..b7bc3876 100644
--- a/05/index.html
+++ b/05/index.html
@@ -1,12 +1,23 @@
+
-
-
+
+
devmentor.pl - JS BASICS - #05
+
-
+
+
+
+
\ No newline at end of file
diff --git a/05/script.js b/05/script.js
new file mode 100644
index 00000000..98c63c87
--- /dev/null
+++ b/05/script.js
@@ -0,0 +1,81 @@
+// konstruktor Student, który przyjmuje argumenty: 'firstName' i 'lastName'
+// oraz posiada właściwość 'grades', która jest obiektem z ocenami studenta
+const Student = function (firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.grades = {
+ // math: [],
+ // english: [],
+ };
+}
+
+// metoda 'addGrade' powinna dodawać ocenę do przedmiotu
+// oraz sprawdzać czy dany przedmiot istnieje w obiekcie 'grades',
+// jeśli nie to ma go dodać
+Student.prototype.addGrade = function (subject, grade) {
+ if(typeof this.grades[subject] === 'undefined') {
+ this.grades[subject] = [];
+ }
+ this.grades[subject].push(grade);
+}
+
+// funkcja licząca średnia z przedmiotu lub przedmiotów do dwóch miejsc po przecinku
+function calculateAverage(grades) {
+ const sum = grades.reduce(function(acc, grade) {
+ return acc + grade}, 0);
+ const average = sum / grades.length;
+ return Math.round(average * 100) / 100;
+}
+
+
+// metoda 'getAverageGrade' powinna zwracać średnią ocen z danego przedmiotu, lub ze wszystkich przedmiotów, jesli nie podamy argumentu
+Student.prototype.getAverageGrade = function (subject) {
+ if(typeof subject !== 'undefined') {
+ const grades = this.grades[subject];
+ console.log(grades);
+
+ return calculateAverage(grades)
+
+ } else {
+ let allGrades = []
+ for(let key in this.grades) {
+ const gradesFromSubject = this.grades[key];
+ allGrades = allGrades.concat(gradesFromSubject);
+ }
+
+ return calculateAverage(allGrades)
+ }
+}
+
+
+const student1 = new Student('Jan', 'Kowalski');
+// const student2 = new Student('Anna', 'Nowak');
+// const student3 = new Student('Piotr', 'Piotrowski');
+
+student1.addGrade('math', 4);
+student1.addGrade('math', 3);
+
+// student2.addGrade('math', 5);
+// student2.addGrade('math', 4);
+
+// student3.addGrade('math', 3);
+// student3.addGrade('math', 5);
+
+student1.addGrade('english', 5);
+// student2.addGrade('english', 3);
+// student3.addGrade('english', 4);
+
+const avgMath = student1.getAverageGrade('math');
+const avgAll = student1.getAverageGrade();
+// const avgMath = student2.getAverageGrade('math');
+// const avgMath = student3.getAverageGrade('math');
+
+
+console.log(student1); // wyswietla obiekt z imieniem, nazwiskiem i ocenami
+
+console.log(avgAll);
+console.log(avgMath);
+console.log(student1.getAverageGrade('math'));
+
+
+