diff --git a/01/assets/js/app.js b/01/assets/js/app.js
index 9323b98d..3e04ff4d 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("a:", typeof a);
+console.log("b:", typeof b);
+
+const operObj = {
+ sum: parseInt(b) + parseInt(a),
+ sub: parseInt(b) - parseInt(a),
+ divd: parseInt(b) / parseInt(a),
+ mult: parseInt(b) * parseInt(a),
+ concat: String(a) + parseInt(b),
+ modulo: parseInt(b) % parseInt(a)
+};
+
+for (const key in operObj) {
+ if (operObj[key] > 20) {
+ console.log(`Wartość ${key} jest większa od 20`);
+ } else if (operObj[key] === 20) {
+ console.log(`Wartość ${key} jest równa 20`)
+ } else if (operObj[key] < 20) {
+ console.log(`Wartość ${key} jest mniejsza niż 20`)
+ } else if (typeof operObj[key] !== "number") {
+ console.log(`Wartość ${key} nie jest ${typeof operObj[key]}`)
+ }
+};
\ No newline at end of file
diff --git a/01/index.html b/01/index.html
index 5c55d687..6f097676 100644
--- a/01/index.html
+++ b/01/index.html
@@ -1,12 +1,21 @@
+
-
-
+
+
devmentor.pl - JS BASICS - #01
+
-
+
+
\ No newline at end of file
diff --git a/02/app.js b/02/app.js
index b397190c..057f614a 100644
--- a/02/app.js
+++ b/02/app.js
@@ -1,7 +1,37 @@
-
/* rozwiązanie z pętlą for */
-const x = 4;
+const x = parseInt(prompt('Podaj liczbę!'));
+
+
+for (let i = 1; i < 10; i++) {
+ const result = x * i;
+ console.log(`${x} * ${i} = ${result}`);
+}
+
+/* rozwiązanie z pętlą while */
+const a = parseInt(prompt('Wprowadź podstawę potęgi!'));
+const n = parseInt(prompt('Wprowadź wykładnik potęgi!'));
+
+if (isNaN(a) || isNaN(n)) {
+ console.error('Wprowadzono nieodpowiedni format danych. Odśwież stronę i spróbuj jeszcze raz!');
+} else {
+ let j = 2;
+ const powResult = Math.pow(a, n);
+ let message = `${a}`
+ if (n === 0) {
+ message = `${a} do potęgi zerowej to zero!`;
+ } else if (n === 1) {
+ message = `${a} do potęgi 1 to ${a}!`;
+ } else if (n === -1) {
+ message = `${a} do potęgi 1 to -${a}!`;
+ } else {
+ while (j <= n) {
+ const addon = ` * ${a}`
+ message = `${message}${addon}`;
-/* rozwiązanie z pętlą while */
\ No newline at end of file
+ j++
+ };
+ console.log(message + ' = ' + powResult);
+ };
+};
\ No newline at end of file
diff --git a/02/index.html b/02/index.html
index 30150099..7261707c 100644
--- a/02/index.html
+++ b/02/index.html
@@ -1,12 +1,21 @@
+
-
-
+
+
devmentor.pl - JS BASICS - #02
+
-
+
+
\ No newline at end of file
diff --git a/03/app.js b/03/app.js
index 5b9361e4..5921a115 100644
--- a/03/app.js
+++ b/03/app.js
@@ -8,11 +8,49 @@ const c = randomNumber(min, max);
console.log(a, b, c);
-
-
-
-
+const isEven = function (int) {
+ if (typeof int === 'number') {
+ if (int % 2 === 0) {
+ return true
+ } else {
+ return false
+ }
+ } else {
+ return null
+ }
+};
function randomNumber(min, max) {
return Math.round((Math.random() * (max - min)) + min);
-}
\ No newline at end of file
+};
+
+function getSum(a, b, c) {
+ const aP = parseInt(a);
+ const bP = parseInt(b);
+ const cP = parseInt(c);
+
+ const min = Math.min(aP, bP, cP);
+ return aP + bP + cP - min
+};
+
+function showInfo(x, y) {
+ switch (y) {
+ case null:
+ console.log(`Podany argument ${x} nie jest liczbą`);
+ break;
+ case true:
+ console.log(`Podany argument ${x} jest parzysty`);
+ break;
+ case false:
+ console.log(`Podany argument ${x} jest nie parzysty`);
+ break;
+ default:
+ console.error('Wprowadzono błędne parametry funkcji showInfo! Parametr "y" przyjmuje wartości: "null", "true" lub "false".')
+ };
+};
+
+
+const sum = getSum(a, b, c);
+const sumIsEven = isEven(sum);
+
+showInfo(sum, sumIsEven);
\ No newline at end of file
diff --git a/04/app.js b/04/app.js
new file mode 100644
index 00000000..f83b204d
--- /dev/null
+++ b/04/app.js
@@ -0,0 +1,30 @@
+const array = createArray(10, 200);
+const top10 = getLargest(array);
+console.log(getAvg(top10));
+
+
+
+
+function createArray(min, max) {
+ const array = [];
+
+ for (let i = 0; i < 20; i++) {
+ const randomNumber = Math.round((Math.random() * (max - min)) + min);
+ array.push(randomNumber);
+ };
+
+ return array
+};
+
+function getLargest(array) {
+ const newArray = array.sort((a, b) => b - a).slice(0, 10);
+ return newArray
+};
+
+function getAvg(array) {
+ const avg = array.reduce((inc, curr) => {
+ return inc += curr
+ }, 0) / array.length;
+
+ return avg
+};
\ No newline at end of file
diff --git a/04/index.html b/04/index.html
index 06aebbb8..961a6455 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/05/app.js b/05/app.js
new file mode 100644
index 00000000..e3c6465f
--- /dev/null
+++ b/05/app.js
@@ -0,0 +1,38 @@
+function Student(firstName, lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.grades = {};
+};
+
+
+Student.prototype.addGrade = function (className, grade) {
+ if (this.grades[className]) {
+ this.grades[className].push(grade)
+ } else (
+ this.grades[className] = [grade]
+ )
+};
+
+Student.prototype.getAverageGrade = function (className) {
+
+ if (!className) {
+ let avg = 0;
+
+ for (const key in this.grades) {
+ const avgKey = this.grades[key].reduce((inc, curr) => {
+ return inc += curr
+ }, 0) / this.grades[key].length;
+ avg += avgKey;
+ }
+
+ return avg / Object.keys(this.grades).length;
+ } else if (typeof className === "string") {
+ const avgSub = this.grades[className].reduce((inc, curr) => {
+ return inc += curr
+ }, 0) / this.grades[className].length;
+
+ return avgSub
+ } else {
+ return console.error('Zły format parametru getAverageGrade()')
+ }
+}
\ No newline at end of file
diff --git a/05/index.html b/05/index.html
index 52a42709..cc0bc931 100644
--- a/05/index.html
+++ b/05/index.html
@@ -1,12 +1,21 @@
+
-
-
+
+
devmentor.pl - JS BASICS - #05
+
-
+
+
\ No newline at end of file