From 4c34c55762ac5f80da1376464329b0e6dc574df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Se=C5=84ko?= Date: Mon, 10 Mar 2025 17:14:42 +0100 Subject: [PATCH 1/3] zad 1 --- 01/app.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/01/app.js b/01/app.js index 96dc2f5..4fab870 100644 --- a/01/app.js +++ b/01/app.js @@ -1,2 +1,10 @@ const randomNumber = Math.round(Math.random() * 20); console.log(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'); +} From 00fd7b8c6cee5f4c004e23460ddc0b958d8c16a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Se=C5=84ko?= Date: Mon, 10 Mar 2025 17:33:41 +0100 Subject: [PATCH 2/3] zad 2 --- 02/app.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 8a41914..fd1c5a6 100644 --- a/02/app.js +++ b/02/app.js @@ -1,2 +1,14 @@ 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(result); + +let i = 1; +while (i <= x) { + result += i; + i++; +} From b90a5e8d88d19085f4b07566a8b4ce6962c9b017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Se=C5=84ko?= Date: Mon, 10 Mar 2025 17:57:06 +0100 Subject: [PATCH 3/3] zad 3 --- 03/app.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/03/app.js b/03/app.js index c26c886..46ab80b 100644 --- a/03/app.js +++ b/03/app.js @@ -1,3 +1,9 @@ const x = 10; let iteration = 0; -let randomNumber = -1; \ No newline at end of file +let randomNumber = -1; + +while (randomNumber !== x) { + randomNumber = Math.round(Math.random() * 21); + iteration++; +} +console.log('Liczba prób: ' + iteration);