diff --git a/01/assets/js/app.js b/01/assets/js/app.js
index 9323b98d..9f669b3b 100644
--- a/01/assets/js/app.js
+++ b/01/assets/js/app.js
@@ -1,4 +1,28 @@
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 addition = Number(a) + b;
+const concatenation = a + b.toString();
+const subtraction = a - b;
+const multiplication = a * b;
+const division = b / a;
+const modulo = b % a;
+
+console.log(
+ `addition: ${addition}, concatenation: ${concatenation}, subtraction: ${subtraction}, multiplication: ${multiplication}, division: ${division}, modulo: ${modulo}`,
+);
+
+const arr = [addition, concatenation, subtraction, multiplication, division, modulo];
+
+arr.forEach(el => {
+ if (Number(el) >= 20) {
+ console.log(`${el} jest większe od 20`);
+ } else {
+ console.log(`${el} jest mniejsze od 20`);
+ }
+});
diff --git a/01/index.html b/01/index.html
index 5c55d687..ae1cffc9 100644
--- a/01/index.html
+++ b/01/index.html
@@ -1,12 +1,15 @@
+
devmentor.pl - JS BASICS - #01
+
-
+
+
\ No newline at end of file
diff --git a/02/app.js b/02/app.js
index b397190c..e0a7b9dd 100644
--- a/02/app.js
+++ b/02/app.js
@@ -1,7 +1,41 @@
-
/* rozwiązanie z pętlą for */
-const x = 4;
+// const x = 4;
+const x = Number(prompt('Podaj liczbę!'));
+
+if (isNaN(x) || x < 1 || x > 9) {
+ console.log('Wpisz poprawną liczbę z zakresu 1-9.');
+} else {
+ for (let i = 1; i < 10; i++) {
+ console.log(`${x} x ${i} = ${x * i}`);
+ }
+}
+
+/* rozwiązanie z pętlą while */
+
+// const a = 3;
+// const n = 4;
+
+const a = Number(prompt('Podaj podstawę potęgi 1-9'));
+const n = Number(prompt('Podaj wykładnik potęgi 1-9'));
+
+if (isNaN(a) || isNaN(n) || a < 1 || a > 9 || n < 1 || n > 9) {
+ console.log('Wpisz poprawną liczbę z zakresu 1-9.');
+} else {
+ let i = 1;
+ let result = 1;
+ let text = '';
+
+ while (i <= n) {
+ result *= a;
+ if (i === n) {
+ text += `${a}`;
+ } else {
+ text += `${a} * `;
+ }
+ i++;
+ }
-/* rozwiązanie z pętlą while */
\ No newline at end of file
+ console.log(`${text} = ${result}`);
+}
diff --git a/02/index.html b/02/index.html
index 30150099..4ed272e1 100644
--- a/02/index.html
+++ b/02/index.html
@@ -1,12 +1,15 @@
+
devmentor.pl - JS BASICS - #02
+
-
+
+
\ No newline at end of file
diff --git a/03/app.js b/03/app.js
index 5b9361e4..dbe30c53 100644
--- a/03/app.js
+++ b/03/app.js
@@ -4,15 +4,47 @@ const max = 100;
const a = randomNumber(min, max);
const b = randomNumber(min, max);
const c = randomNumber(min, max);
+// const a = 21;
+// const b = 33;
+// const c = 21;
console.log(a, b, c);
-
-
-
-
-
+function getSum(num1, num2, num3) {
+ const intNum1 = parseInt(num1);
+ const intNum2 = parseInt(num2);
+ const intNum3 = parseInt(num3);
+
+ return [intNum1, intNum2, intNum3]
+ .sort((a, b) => a - b)
+ .slice(-2)
+ .reduce((acc, curr) => acc + curr, 0);
+}
+
+const isEven = function (num) {
+ return typeof num !== 'number' ? null : num % 2 === 0;
+};
+
+const showInfo = (val, flag) => {
+ switch (flag) {
+ case null:
+ console.log(`Podany argument ${val} nie jest liczbą`);
+ break;
+ case true:
+ console.log(`Podany argument ${val} jest parzysty`);
+ break;
+ case false:
+ console.log(`Podany argument ${val} jest nieparzysty`);
+ break;
+ default:
+ console.log('Drugi parametr musi być: null, true lub false');
+ }
+};
function randomNumber(min, max) {
- return Math.round((Math.random() * (max - min)) + min);
-}
\ No newline at end of file
+ return Math.round(Math.random() * (max - min) + min);
+}
+
+const totalSum = getSum(a, b, c);
+const isNumberIsEven = isEven(totalSum);
+showInfo(totalSum, isNumberIsEven);
diff --git a/04/app.js b/04/app.js
new file mode 100644
index 00000000..6b418a6f
--- /dev/null
+++ b/04/app.js
@@ -0,0 +1,28 @@
+const min = 1;
+const max = 100;
+
+const arr = createArray(1, 100);
+console.log(arr);
+
+const largest = getLargest(arr);
+console.log(largest);
+
+const avg = getAvg(largest);
+console.log(avg);
+
+function createArray(min, max) {
+ const arr = [];
+ for (let i = 0; i < 20; i++) {
+ const num = Math.round(Math.random() * (max - min) + min);
+ arr.push(num);
+ }
+ return arr;
+}
+
+function getLargest(array) {
+ return array.sort((a, b) => b - a).slice(0, 10);
+}
+
+function getAvg(array) {
+ return array.reduce((acc, curr) => acc + curr, 0) / array.length;
+}
diff --git a/04/index.html b/04/index.html
index 06aebbb8..65888d5a 100644
--- a/04/index.html
+++ b/04/index.html
@@ -1,12 +1,15 @@
+
devmentor.pl - JS BASICS - #04
+
-
+
+
\ No newline at end of file
diff --git a/05/app.js b/05/app.js
new file mode 100644
index 00000000..9c46ff4a
--- /dev/null
+++ b/05/app.js
@@ -0,0 +1,44 @@
+function Student(initFirstName, initLastName) {
+ this.firstName = initFirstName;
+ this.lastName = initLastName;
+ this.grades = {};
+}
+
+Student.prototype.addGrade = function (subject, grade) {
+ if (!this.grades[subject]) {
+ this.grades[subject] = [];
+ }
+ return this.grades[subject].push(grade);
+};
+
+Student.prototype.getAverageGrade = function (subject) {
+ if (!subject) {
+ const newArr = [];
+ for (const sub in this.grades) {
+ newArr.push(...this.grades[sub]);
+ }
+ return this.calculateAverage(newArr);
+ } else {
+ if (!this.grades[subject]) {
+ return 'Nie ma takiego przedmiotu';
+ } else {
+ return this.calculateAverage(this.grades[subject]);
+ }
+ }
+};
+
+Student.prototype.calculateAverage = function (arr) {
+ return Number((arr.reduce((acc, curr) => acc + curr, 0) / arr.length).toFixed(2));
+};
+
+const student = new Student('Jan', 'Kowalski');
+student.addGrade('maths', 4);
+student.addGrade('maths', 6);
+student.addGrade('english', 3);
+console.log(student);
+const avgMath = student.getAverageGrade('maths');
+const avgMath1 = student.getAverageGrade('math');
+console.log(avgMath);
+console.log(avgMath1);
+const avg = student.getAverageGrade();
+console.log(avg);
diff --git a/05/index.html b/05/index.html
index 52a42709..0dfb10b7 100644
--- a/05/index.html
+++ b/05/index.html
@@ -7,6 +7,6 @@
devmentor.pl - JS BASICS - #05
-
+