From 104584f3f7c258f5c3e324ed99c42d81ffe63aeb Mon Sep 17 00:00:00 2001 From: Michal Wasiak Date: Sun, 18 May 2025 15:06:36 +1000 Subject: [PATCH 1/3] Task 01 done --- 01/app.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/01/app.js b/01/app.js index 96dc2f5..fc5a1cf 100644 --- a/01/app.js +++ b/01/app.js @@ -1,2 +1,12 @@ -const randomNumber = Math.round(Math.random() * 20); -console.log(randomNumber); +const randomNumber = Math.round(Math.random() * 21); +// let number = randomNumber; + +console.log('Wylosowana liczba to: ' + randomNumber) + +if (randomNumber >= 5) { + for (let i = 5; i <= randomNumber; i++) { + console.log(i); + } +} else { + console.log("Wylosowana liczba jest zbyt mała, aby użyć pętli."); +} \ No newline at end of file From 5b9cff92149d5fe283e6141cd1a670758c00f2ef Mon Sep 17 00:00:00 2001 From: Michal Wasiak Date: Sun, 18 May 2025 15:25:37 +1000 Subject: [PATCH 2/3] Task 02 done --- 02/app.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 8a41914..2ebbee6 100644 --- a/02/app.js +++ b/02/app.js @@ -1,2 +1,19 @@ const x = 5; -let result = 0; \ No newline at end of file +let result = 0; + +for (let i = 1; i <= x; i++) { + result += i; +} + +console.log("Wynik przy użyciu pętli for:", result); + +const y = 5; +let result2 = 0; +let j = 1; + +while (j <= y) { + result2 += j; + j++; +} + +console.log("Wynik przy użyciu pętli while:", result2); From 6860b143ebb821b59eedf6286c5980bb10cc5c6d Mon Sep 17 00:00:00 2001 From: Michal Wasiak Date: Sun, 18 May 2025 15:34:19 +1000 Subject: [PATCH 3/3] Task 03 done --- 03/app.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/03/app.js b/03/app.js index c26c886..53f0b68 100644 --- a/03/app.js +++ b/03/app.js @@ -1,3 +1,11 @@ -const x = 10; +const x = 5; let iteration = 0; -let randomNumber = -1; \ No newline at end of file +let randomNumber = -1; + + +while (randomNumber !== x) { + randomNumber = Math.floor(Math.random() * 21); + iteration++; +} + +console.log("Liczba x została wylosowana po", iteration, "próbach."); \ No newline at end of file